@openchambery/web 2.0.0-beta.10 → 2.0.0-beta.12
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/{AgentAvatar-CzTtVMnI.js → AgentAvatar-pLaqWWmB.js} +1 -1
- package/dist/assets/AssistantView-DZ0JKlUo.js +3 -0
- package/dist/assets/{DiagramView-hOi72Wdx.js → DiagramView--pU6ohnA.js} +1 -1
- package/dist/assets/{FadeInOnReveal-DCqrQkkz.js → FadeInOnReveal-MuJAzJq_.js} +1 -1
- package/dist/assets/{Icon-B8fSTLdP.js → Icon-Dz2kO9RN.js} +1 -1
- package/dist/assets/{MarkdownRenderer-Cw74oVxV.js → MarkdownRenderer-38oU4xtI.js} +2 -2
- package/dist/assets/{MarkdownRendererImpl-YM7iRmzK.js → MarkdownRendererImpl-BmaQCjcI.js} +3 -3
- package/dist/assets/{MarkstreamRendererImpl-BDy_oGJQ.js → MarkstreamRendererImpl-DsK1uz-k.js} +1 -1
- package/dist/assets/{MobileDetailNavigation-iX_hb_Xt.js → MobileDetailNavigation-6fKfAuI8.js} +1 -1
- package/dist/assets/{MobileShareBridge-CAMUupwR.js → MobileShareBridge-C71kg-60.js} +1 -1
- package/dist/assets/MobileSurface-BFUgve3c.js +2 -0
- package/dist/assets/{MultiRunWindow-Ci1ODFFX.js → MultiRunWindow-CLn3DKGh.js} +1 -1
- package/dist/assets/{OnboardingScreen-O4cGdz5p.js → OnboardingScreen-XWkr7MjT.js} +1 -1
- package/dist/assets/{OverlayScrollbar-CRfGtcmG.js → OverlayScrollbar-DCWyGseO.js} +1 -1
- package/dist/assets/SettingsView-BgkJZ9di.js +25 -0
- package/dist/assets/{SettingsWindow-B8d8qIQ7.js → SettingsWindow-BEeczSGh.js} +1 -1
- package/dist/assets/{TerminalView-CMiw3s_c.js → TerminalView-C4IN1OjP.js} +1 -1
- package/dist/assets/{ToolOutputDialog-ByaQYRTp.js → ToolOutputDialog-CqaiiT1U.js} +1 -1
- package/dist/assets/{appThemeRegistry-BGGHio8T.js → appThemeRegistry-iIISIT3M.js} +1 -1
- package/dist/assets/{button-DIIrsMjW.js → button-Doq9FI1I.js} +1 -1
- package/dist/assets/{collapsible-CnvUeYst.js → collapsible-CYUeu3_N.js} +1 -1
- package/dist/assets/{context-menu-BGBUpZEQ.js → context-menu-C8kOMVtC.js} +1 -1
- package/dist/assets/{desktopHosts-JGFqhlaM.js → desktopHosts-DbxnIQdS.js} +1 -1
- package/dist/assets/{desktopRelayRestore-CHEwrI93.js → desktopRelayRestore-dvxF4V2p.js} +1 -1
- package/dist/assets/{diagram-rvn7_qBM.js → diagram-B1p9Yn1h.js} +1 -1
- package/dist/assets/{dialog-CQ63sc9E.js → dialog-D08-Lg-e.js} +1 -1
- package/dist/assets/{fileMentionTouchSelection-BzzcWJCi.js → fileMentionTouchSelection-CRd9V2j3.js} +1 -1
- package/dist/assets/{fileQueries-DN6gbLhM.js → fileQueries-X773xxvX.js} +1 -1
- package/dist/assets/{gitApi-BF8vuoZc.js → gitApi-Defy-gVu.js} +4 -4
- package/dist/assets/{input-BVu-iykl.js → input-DZZuQ1IL.js} +1 -1
- package/dist/assets/insertionBoundaries-Dn1Al9mx.js +1 -0
- package/dist/assets/main-BF8yvTbG.js +169 -0
- package/dist/assets/{main-B7t9lavz.js → main-DFJ23aoT.js} +2 -2
- package/dist/assets/{markdownHeightCache-D9-B1wdY.js → markdownHeightCache-DBgXGze8.js} +1 -1
- package/dist/assets/{mcpQueries-CfXrAkuU.js → mcpQueries-Cgf6MdLa.js} +1 -1
- package/dist/assets/{miniChat-DgOrEQbN.js → miniChat-Bpvko0j9.js} +2 -2
- package/dist/assets/{mobile-Co_ZOHkZ.js → mobile-3sunRAXX.js} +2 -2
- package/dist/assets/multirun-CRhkfJum.js +4 -0
- package/dist/assets/persistence-DznVIKwz.js +3 -0
- package/dist/assets/platform-DSTtx-DI.js +6 -0
- package/dist/assets/{projectMeta-CPElzJ0n.js → projectMeta-BXR_V6FR.js} +2 -2
- package/dist/assets/{renderElectronMiniChatApp-pOE93w86.js → renderElectronMiniChatApp-BT8rVrtX.js} +2 -2
- package/dist/assets/renderMobileApp-DoE5q0Ob.js +28 -0
- package/dist/assets/{runtimeConfig-DSS0KxG3.js → runtimeConfig-B88-ZivS.js} +1 -1
- package/dist/assets/{runtimeEndpointReset-x2Wgx57R.js → runtimeEndpointReset-DMiw-qyY.js} +7 -7
- package/dist/assets/{sessionChangeSummary-BUGSYcHp.js → sessionChangeSummary-BuOczB_t.js} +2 -2
- package/dist/assets/{sessionLookup-Bss8M20i.js → sessionLookup-CYbs1Lsc.js} +1 -1
- package/dist/assets/{sortable-tabs-strip-CE7W7lJ9.js → sortable-tabs-strip-Q3bb6MVj.js} +1 -1
- package/dist/assets/{terminalApi-mDR2jXTo.js → terminalApi-Da_DO_Uh.js} +1 -1
- package/dist/assets/{textarea-XD2oX_Ee.js → textarea--CYehp07.js} +1 -1
- package/dist/assets/{tooltip-DYeQ_Hvy.js → tooltip-CGLzBwEK.js} +1 -1
- package/dist/assets/{url-CGbJbiJq.js → url-Byz3kd29.js} +1 -1
- package/dist/assets/{useAppFontEffects-BAWHZ-t0.js → useAppFontEffects-CXh2NTBX.js} +55 -55
- package/dist/assets/{useDesktopWindowControlsLayout-hN_nLb7T.js → useDesktopWindowControlsLayout-BPqsR_Z4.js} +1 -1
- package/dist/assets/{useEffectiveDirectory-Do9DQ453.js → useEffectiveDirectory-DvYPK8Aw.js} +1 -1
- package/dist/assets/{useFontPreferences-Bjx8zkGM.js → useFontPreferences-D9OIZs1p.js} +1 -1
- package/dist/assets/useMobileNavigationStore-CBw22aun.js +414 -0
- package/dist/assets/useSessionAutoCleanup-BuAJaaCz.js +2 -0
- package/dist/assets/{useWorkerHighlightedLines-B5QXxBok.js → useWorkerHighlightedLines-BKdTJ37z.js} +1 -1
- package/dist/index.html +7 -7
- package/dist/mini-chat.html +7 -7
- package/dist/mobile.html +7 -7
- package/package.json +1 -1
- package/dist/assets/AssistantView-Cg1qQvVe.js +0 -3
- package/dist/assets/MobileSurface-CHbdPcLH.js +0 -2
- package/dist/assets/SettingsView-Dg8BtTV1.js +0 -25
- package/dist/assets/insertionBoundaries-EcAfGT2D.js +0 -1
- package/dist/assets/main-DWP-prNB.js +0 -169
- package/dist/assets/multirun-DelyUO6k.js +0 -4
- package/dist/assets/persistence-D0y7226-.js +0 -3
- package/dist/assets/platform-CurqO28D.js +0 -6
- package/dist/assets/renderMobileApp-F7ZSLcw8.js +0 -28
- package/dist/assets/useMobileNavigationStore-BsY_gi_K.js +0 -414
- package/dist/assets/useSessionAutoCleanup-C4g5KmDf.js +0 -2
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import{o as e,r as t}from"./rolldown-runtime-C0FnF6B9.js";import{E as n}from"./runtime-auth-D66yq6ie.js";import{c as r,i,l as a,n as o,r as s,t as c}from"./runtime-switch-LvWDU-SL.js";import{n as l}from"./runtime-fetch-Fs9ZV2V8.js";import{$t as u,A as d,Cn as f,D as p,Gt as m,Kt as h,O as g,Qt as _,Ut as v,Wt as y,Xt as b,Yt as x,_n as S,a as C,d as w,dn as T,f as E,i as D,k as O,nn as k,p as A,pn as j,r as M,rn as N,rt as P,u as F,vn as I,wn as L,yn as R,z}from"./persistence-DznVIKwz.js";import{a as B,g as V,h as H,i as U,l as W,m as ee,n as G,p as te,r as ne,t as re,u as ie}from"./desktopHosts-DbxnIQdS.js";import{n as ae}from"./desktopRelayRestore-dvxF4V2p.js";import{a as oe,i as se,r as ce,t as le}from"./vendor-zustand-B4dlGEM2.js";import{nt as ue,rt as de}from"./vendor-base-ui-CnHfUmDN.js";import{Ct as fe,Nt as pe,n as me,t as he}from"./platform-DSTtx-DI.js";import{b as ge,d as _e,i as ve,n as K,o as ye,s as be}from"./useUIStore-syVmbuDA.js";import{n as xe}from"./vendor-react-DLPElpoQ.js";import{n as Se}from"./vendor-aparajita-capacitor-secure-storage-CjQdwfjS.js";import{l as Ce,n as we,o as Te,s as Ee}from"./vendor-tanstack-react-query-D7pys_c9.js";import{W as De}from"./vendor-codemirror-autocomplete-DHomsvW7.js";import{r as Oe}from"./vendor-sonner-DVzioF3d.js";import{c as ke,n as Ae}from"./vendor-reactuses-core-Dq5ocTF8.js";import{d as je,f as Me,o as Ne,p as Pe,r as q,t as J}from"./button-Doq9FI1I.js";import{a as Fe,i as Ie,r as Le}from"./MobileShareBridge-C71kg-60.js";import{_ as Re,a as ze,d as Be,g as Ve,h as He,i as Ue,m as We,s as Ge,t as Ke,v as qe,x as Je,y as Ye}from"./MobileDetailNavigation-6fKfAuI8.js";import{$a as Xe,$i as Ze,Aa as Qe,Ba as $e,Da as et,Dr as Y,Ea as tt,Fa as nt,Ga as rt,Ha as it,Ia as at,Ja as ot,Ji as st,Ka as ct,La as lt,Ln as ut,Ma as dt,Na as ft,Oa as pt,Pa as mt,Qa as ht,Qi as gt,Ra as _t,Rn as vt,Ta as yt,Ua as bt,Va as xt,Wa as St,Ya as Ct,Yi as wt,Yt as Tt,Zi as Et,aa as Dt,bi as Ot,ca as kt,eo as At,hi as jt,ia as Mt,ja as Nt,ka as Pt,la as Ft,mi as It,o as Lt,pi as Rt,qa as zt,qi as Bt,sa as Vt,ua as Ht,ui as Ut,wa as Wt,za as Gt}from"./useMobileNavigationStore-CBw22aun.js";import{i as Kt}from"./useAssistantUIStore-Bz4tRflF.js";import{a as qt,i as Jt,n as Yt,o as Xt,r as Zt,t as Qt}from"./dialog-D08-Lg-e.js";import{t as $t}from"./AgentAvatar-pLaqWWmB.js";import{n as X}from"./Icon-Dz2kO9RN.js";import{T as en,_ as tn,a as nn,b as rn,h as an,i as on,j as sn,k as cn,m as ln,n as un,x as dn}from"./projectMeta-BXR_V6FR.js";import{t as fn}from"./input-DZZuQ1IL.js";import{i as pn,n as mn,t as hn}from"./tooltip-CGLzBwEK.js";import{At as gn,Bt as _n,Ct as vn,E as yn,F as bn,Ft as xn,Ht as Sn,I as Cn,It as wn,J as Tn,K as En,L as Dn,Lt as On,Mt as kn,N as An,Nt as jn,O as Mn,Pt as Nn,Qt as Pn,R as Fn,Rt as Z,St as In,T as Ln,V as Rn,Vt as zn,Wt as Bn,Zt as Vn,a as Hn,an as Un,at as Wn,bt as Gn,ct as Kn,dt as qn,en as Jn,gt as Yn,ht as Xn,i as Zn,it as Qn,j as $n,jt as er,k as tr,kt as nr,mt as rr,nn as ir,o as ar,on as or,rn as sr,rt as cr,st as lr,t as ur,tn as dr,tt as fr,u as pr,ut as mr,xt as hr,z as gr,zt as _r}from"./useSessionAutoCleanup-BuAJaaCz.js";import{n as vr}from"./useThemeSystem-DMzWVJaW.js";import{i as yr,r as br}from"./OverlayScrollbar-DCWyGseO.js";import{n as xr}from"./useRuntimeAPIs-DSLXJybW.js";import{n as Sr,t as Cr}from"./textarea--CYehp07.js";import{P as wr,i as Tr,j as Er,n as Dr}from"./appThemeRegistry-iIISIT3M.js";import{n as Or}from"./MarkdownRenderer-38oU4xtI.js";import{a as kr}from"./url-Byz3kd29.js";import{l as Ar}from"./markdown-worker-bS5OgGO3.js";import{t as jr}from"./sortable-tabs-strip-Q3bb6MVj.js";import{A as Mr,B as Nr,C as Pr,D as Fr,E as Ir,F as Lr,G as Rr,H as zr,I as Br,J as Vr,K as Hr,L as Ur,M as Wr,N as Gr,O as Kr,P as qr,R as Jr,S as Yr,T as Xr,U as Zr,V as Qr,W as $r,Y as ei,_ as ti,a as ni,b as ri,c as ii,f as ai,g as oi,h as si,j as ci,k as li,l as ui,m as di,n as fi,q as pi,s as mi,u as hi,v as gi,x as _i,z as vi}from"./MobileSurface-BFUgve3c.js";import{a as yi,c as bi,i as xi,l as Si,o as Ci,r as wi,s as Ti}from"./mcpQueries-Cgf6MdLa.js";import{a as Ei,n as Di,r as Oi,t as ki}from"./context-menu-C8kOMVtC.js";import{n as Ai,r as ji,t as Mi}from"./collapsible-CYUeu3_N.js";import{n as Ni,t as Pi}from"./vendor-yaml-C9KlJAlj.js";import{t as Fi}from"./vendor-qrcode-DAuVxiQR.js";var Ii=xe(),Q=e(de(),1),$=ue(),Li=`https://github.com/yee94/openchamber`,Ri=`${Li}/issues/new`,zi=`https://discord.gg/ZYRSdnwwKA`,Bi=`https://x.com/openchamber_dev`,Vi=800,Hi={"manual-global":`settings.openchamber.about.opencodeManagement.manual-global`,"manual-external":`settings.openchamber.about.opencodeManagement.manual-external`,bundled:`settings.openchamber.about.opencodeManagement.bundled`,"in-app":`settings.openchamber.about.opencodeManagement.in-app`,none:`settings.openchamber.about.opencodeManagement.none`},Ui=e=>typeof e==`string`&&e.trim()?e.trim():null,Wi=(e,t,n)=>({queryKey:[t,`about`,n,e],queryFn:async({signal:r})=>{if(t!==i()||n!==o())throw Error(`Stale About runtime`);let a=await l(e,{method:`GET`,headers:{Accept:`application/json`},signal:r});if(!a.ok)throw Error(`About snapshot: ${a.status}`);let s=await a.json();if(!s||typeof s!=`object`||Array.isArray(s))throw Error(`Invalid About snapshot`);if(r.aborted||t!==i()||n!==o())throw Error(`Stale About runtime`);return s},retry:!1,staleTime:3e4}),Gi=()=>{try{let e=Se;return((typeof e.getConfig==`function`?e.getConfig():void 0)??e.config)?.OpenChamberOTA?.channel===`stable`?`stable`:`beta`}catch{return`beta`}},Ki=({initialUpdateDialogOpen:e=!1})=>{let{t}=Me(),[n,a]=Q.useState(e),[s,c]=Q.useState(!1),[l,u]=Q.useState(!1),[d,f]=Q.useState(null),[p,m]=Q.useState(null),h=Q.useSyncExternalStore(r,i,i),g=Q.useSyncExternalStore(r,o,o),_=Ee(Wi(`/api/system/info`,h,g)),v=Ee(Wi(`/api/opencode/upgrade-status`,h,g)),y=Ui(_.data?.openchamberVersion),b=v.data,x=Ui(b?.serveVersion)??Ui(b?.currentVersion),S=Ui(b?.management),C=S&&Object.hasOwn(Hi,S)?Hi[S]:null,w=b?.canManage===!1&&C?t(C):null,T=x&&w?t(`settings.openchamber.about.opencodeVersionWithManagement`,{version:x,management:w}):x,E=b?.canManage===!1?S===`manual-global`?t(`settings.openchamber.about.opencodeGuidance.manualGlobal`):S===`manual-external`?t(`settings.openchamber.about.opencodeGuidance.manualExternal`):S===`bundled`?t(`settings.openchamber.about.opencodeGuidance.bundled`):null:null,D=Zr(le(e=>({info:e.info,checking:e.checking,available:e.available,error:e.error,downloading:e.downloading,downloaded:e.downloaded,progress:e.progress,runtimeType:e.runtimeType,checkForUpdates:e.checkForUpdates,downloadUpdate:e.downloadUpdate,restartToUpdate:e.restartToUpdate}))),{isMobile:O}=yr(),k=K(e=>e.otaChannelOverride),A=K(e=>e.setOtaChannelOverride),j=me(),M=Gi(),N=k===`beta`||k===null&&M===`beta`,[P,F]=Q.useState(!1),[I,L]=Q.useState(()=>jt()),R=Ae(e=>{Ot(e),L(e)}),z=Ae(async e=>{if(e){A(`beta`),await Zr.getState().checkForUpdates();return}A(`stable`),await Zr.getState().checkForUpdates();let{info:t,otaDecision:n}=Zr.getState();t?.isChannelRollback===!0&&n?.primaryAction===`apply_ota`&&c(!0)}),B=Ae(()=>{c(!1),A(`beta`),Zr.getState().checkForUpdates()}),V=Ae(()=>{c(!1),a(!0),Zr.getState().downloadUpdate()}),H=Ae(e=>{e||B()}),U=d||t(`settings.openchamber.about.state.unknown`),W=Ae(async()=>{if(!P){F(!0);try{let{outcome:e,eventCount:n}=await It();if(e===`cancelled`)return;if(e===`failed`){Y.error(t(`settings.openchamber.about.diagnostics.toast.failed`));return}Y.success(t(n>0?`settings.openchamber.about.diagnostics.toast.exported`:`settings.openchamber.about.diagnostics.toast.empty`))}catch{Y.error(t(`settings.openchamber.about.diagnostics.toast.failed`))}finally{F(!1)}}});Q.useEffect(()=>{let e=!1;return Hr().then(t=>{e||f(t)}),Rr().then(t=>{e||m(t)}),()=>{e=!0}},[]);let ee=$r(d,p)??U,G=Q.useRef(!1);Q.useEffect(()=>{if(D.checking)u(!0),G.current=!0;else if(l){let e=setTimeout(()=>{u(!1),G.current&&D.error?(Y.error(t(`settings.openchamber.about.toast.checkFailed`),{description:D.error}),G.current=!1):G.current&&!D.available&&!D.error&&(Y.success(t(`settings.openchamber.about.toast.latestVersion`)),G.current=!1)},Vi);return()=>clearTimeout(e)}},[t,D.checking,l,D.available,D.error]);let te=D.checking||l;return O?(0,$.jsxs)(`div`,{className:`w-full space-y-6 pb-2`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col items-center text-center`,children:[(0,$.jsx)(Z,{width:72,height:72}),(0,$.jsx)(`h2`,{className:`mt-4 typography-ui-header font-semibold text-foreground`,children:`OpenChamber`})]}),(0,$.jsxs)(vi,{children:[(0,$.jsx)(Nr,{label:t(`settings.openchamber.about.field.clientVersion`),children:(0,$.jsx)(`span`,{className:`typography-ui-label font-mono text-foreground text-right`,children:ee})}),(0,$.jsx)(Nr,{label:t(`settings.openchamber.about.field.instanceOpenChamberVersion`),children:(0,$.jsx)(`span`,{className:`typography-ui-label font-mono text-foreground text-right`,children:y||t(`settings.openchamber.about.state.unknown`)})}),(0,$.jsx)(Nr,{label:t(`settings.openchamber.about.field.instanceOpenCodeVersion`),description:E,children:(0,$.jsx)(`span`,{className:`typography-ui-label font-mono text-foreground text-right`,children:T||t(`settings.openchamber.about.state.unknown`)})}),(0,$.jsx)(Nr,{children:(0,$.jsxs)(`div`,{className:`flex flex-nowrap items-center justify-end gap-2`,children:[(0,$.jsx)(J,{asChild:!0,variant:`outline`,size:`sm`,className:`whitespace-nowrap`,children:(0,$.jsxs)(`a`,{href:Ri,target:`_blank`,rel:`noopener noreferrer`,children:[(0,$.jsx)(X,{name:`question`,className:`size-4`}),t(`settings.openchamber.about.actions.submitFeedback`)]})}),!te&&D.available?(0,$.jsxs)(J,{type:`button`,variant:`default`,size:`sm`,className:`whitespace-nowrap`,onClick:()=>a(!0),children:[(0,$.jsx)(X,{name:`download`,className:`size-4`}),D.info?.inAppApply?t(`settings.openchamber.about.actions.applyOtaToVersion`,{version:D.info?.version||``}):D.info?.manualUpdate?t(`settings.openchamber.about.actions.installNativeToVersion`,{version:D.info?.version||``}):t(`settings.openchamber.about.actions.updateToVersion`,{version:D.info?.version||``})]}):(0,$.jsxs)(J,{type:`button`,variant:`outline`,size:`sm`,className:`whitespace-nowrap`,onClick:()=>D.checkForUpdates(),disabled:te,children:[te?(0,$.jsx)(X,{name:`loader`,className:`size-4 animate-spin`}):(0,$.jsx)(X,{name:`refresh`,className:`size-4`}),t(te?`settings.openchamber.about.state.checking`:`settings.openchamber.about.actions.checkForUpdates`)]})]})}),D.error&&(0,$.jsx)(Nr,{children:(0,$.jsx)(`p`,{className:`typography-meta text-[var(--status-error)]`,children:D.error})}),j&&(0,$.jsx)(Qr,{itemId:`about.beta-updates`,checked:N,onChange:z,label:t(`settings.openchamber.about.betaUpdates.label`),description:t(`settings.openchamber.about.betaUpdates.description`),ariaLabel:t(`settings.openchamber.about.betaUpdates.label`),disabled:te}),(0,$.jsx)(Qr,{itemId:`about.diagnostics`,checked:I,onChange:R,label:t(`settings.openchamber.about.diagnostics.label`),ariaLabel:t(`settings.openchamber.about.diagnostics.label`)}),I&&(0,$.jsx)(Nr,{itemId:`about.export-diagnostics`,label:t(`settings.openchamber.about.diagnostics.export`),children:(0,$.jsx)(J,{type:`button`,variant:`outline`,size:`sm`,disabled:P,onClick:()=>void W(),children:t(P?`settings.openchamber.about.diagnostics.exporting`:`settings.openchamber.about.diagnostics.export`)})})]}),(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-3 text-center`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-center gap-5`,children:[(0,$.jsxs)(`a`,{href:Li,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1.5 typography-ui-label text-muted-foreground transition-colors hover:text-foreground`,children:[(0,$.jsx)(X,{name:`github-fill`,className:`size-5`}),(0,$.jsx)(`span`,{children:`GitHub`})]}),(0,$.jsxs)(`a`,{href:zi,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1.5 typography-ui-label text-muted-foreground transition-colors hover:text-foreground`,children:[(0,$.jsx)(X,{name:`discord-fill`,className:`size-5`}),(0,$.jsx)(`span`,{children:`Discord`})]})]}),(0,$.jsxs)(`a`,{href:Bi,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1.5 typography-ui-label text-muted-foreground transition-colors hover:text-foreground`,children:[(0,$.jsx)(X,{name:`twitter-xfill`,className:`size-5`}),(0,$.jsx)(`span`,{children:`@openchamber_dev`})]})]}),(0,$.jsx)(`p`,{className:`text-center typography-ui text-muted-foreground/60`,children:t(`aboutDialog.footerNote`)}),(0,$.jsx)(zr,{open:n,onOpenChange:a,info:D.info,downloading:D.downloading,downloaded:D.downloaded,progress:D.progress,error:D.error,onDownload:D.downloadUpdate,onRestart:D.restartToUpdate,runtimeType:D.runtimeType}),(0,$.jsx)(Qt,{open:s,onOpenChange:H,children:(0,$.jsxs)(Yt,{showCloseButton:!1,className:`max-w-sm gap-5`,children:[(0,$.jsxs)(qt,{children:[(0,$.jsx)(Xt,{children:t(`settings.openchamber.about.betaUpdates.rollback.title`)}),(0,$.jsx)(Zt,{children:t(`settings.openchamber.about.betaUpdates.rollback.description`,{version:D.info?.version||``})})]}),(0,$.jsxs)(Jt,{children:[(0,$.jsx)(J,{type:`button`,size:`sm`,variant:`ghost`,onClick:B,children:t(`settings.openchamber.about.betaUpdates.rollback.actions.cancel`)}),(0,$.jsx)(J,{type:`button`,size:`sm`,onClick:V,children:t(`settings.openchamber.about.betaUpdates.rollback.actions.confirm`)})]})]})})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(vi,{label:t(`settings.openchamber.about.title`),children:[(0,$.jsx)(Nr,{label:t(`settings.openchamber.about.field.clientVersion`),children:(0,$.jsx)(`span`,{className:`typography-ui-label font-mono text-foreground text-right`,children:U})}),(0,$.jsx)(Nr,{label:t(`settings.openchamber.about.field.instanceOpenChamberVersion`),children:(0,$.jsx)(`span`,{className:`typography-ui-label font-mono text-foreground text-right`,children:y||t(`settings.openchamber.about.state.unknown`)})}),(0,$.jsx)(Nr,{label:t(`settings.openchamber.about.field.instanceOpenCodeVersion`),description:E,children:(0,$.jsx)(`span`,{className:`typography-ui-label font-mono text-foreground text-right`,children:T||t(`settings.openchamber.about.state.unknown`)})}),(0,$.jsx)(Nr,{children:(0,$.jsxs)(`div`,{className:`flex flex-nowrap items-center justify-end gap-3`,children:[(0,$.jsx)(J,{asChild:!0,variant:`outline`,size:`sm`,className:`whitespace-nowrap`,children:(0,$.jsxs)(`a`,{href:Ri,target:`_blank`,rel:`noopener noreferrer`,children:[(0,$.jsx)(X,{name:`question`,className:`size-4`}),t(`settings.openchamber.about.actions.submitFeedback`)]})}),D.checking&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-muted-foreground`,children:[(0,$.jsx)(X,{name:`loader`,className:`h-4 w-4 animate-spin`}),(0,$.jsx)(`span`,{className:`typography-meta`,children:t(`settings.openchamber.about.state.checking`)})]}),!D.checking&&D.available&&(0,$.jsxs)(J,{size:`sm`,variant:`default`,onClick:()=>a(!0),children:[(0,$.jsx)(X,{name:`download`,className:`h-4 w-4 mr-1`}),t(`settings.openchamber.about.actions.updateToVersion`,{version:D.info?.version||``})]}),!D.checking&&!D.available&&!D.error&&(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:t(`settings.openchamber.about.state.upToDate`)}),(0,$.jsx)(J,{size:`sm`,variant:`outline`,onClick:()=>D.checkForUpdates(),disabled:D.checking,children:t(`settings.openchamber.about.actions.checkForUpdates`)})]})}),D.error&&(0,$.jsx)(Nr,{children:(0,$.jsx)(`p`,{className:`typography-meta text-[var(--status-error)]`,children:D.error})}),(0,$.jsx)(Qr,{itemId:`about.diagnostics`,checked:I,onChange:R,label:t(`settings.openchamber.about.diagnostics.label`),ariaLabel:t(`settings.openchamber.about.diagnostics.label`)}),I&&(0,$.jsx)(Nr,{itemId:`about.export-diagnostics`,label:t(`settings.openchamber.about.diagnostics.export`),children:(0,$.jsx)(J,{type:`button`,variant:`outline`,size:`sm`,disabled:P,onClick:()=>void W(),children:t(P?`settings.openchamber.about.diagnostics.exporting`:`settings.openchamber.about.diagnostics.export`)})}),(0,$.jsxs)(Nr,{controlClassName:`flex-wrap`,children:[(0,$.jsxs)(`a`,{href:Li,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1.5 text-muted-foreground hover:text-foreground typography-meta transition-colors`,children:[(0,$.jsx)(X,{name:`github-fill`,className:`h-4 w-4`}),(0,$.jsx)(`span`,{children:`GitHub`})]}),(0,$.jsxs)(`a`,{href:Bi,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1.5 text-muted-foreground hover:text-foreground typography-meta transition-colors`,children:[(0,$.jsx)(X,{name:`twitter-xfill`,className:`h-4 w-4`}),(0,$.jsx)(`span`,{children:`@openchamber_dev`})]})]})]}),(0,$.jsx)(zr,{open:n,onOpenChange:a,info:D.info,downloading:D.downloading,downloaded:D.downloaded,progress:D.progress,error:D.error,onDownload:D.downloadUpdate,onRestart:D.restartToUpdate,runtimeType:D.runtimeType})]})},qi=`/assets/android-direct-share-1a0lp154.jpg`,Ji=`/assets/ios-share-sheet-B3Dlufnc.jpg`,Yi=`/assets/select-assistant-C89IRspC.jpg`,Xi=`openchamber:assistant-share-welcome:v1`,Zi=[{image:Ji,titleKey:`assistants.shareWelcome.example.chat.title`,descriptionKey:`assistants.shareWelcome.example.chat.description`},{image:qi,titleKey:`assistants.shareWelcome.example.article.title`,descriptionKey:`assistants.shareWelcome.example.article.description`},{image:Yi,titleKey:`assistants.shareWelcome.example.note.title`,descriptionKey:`assistants.shareWelcome.example.note.description`}],Qi=e=>{let t=(0,Ii.c)(40),{enabled:n,open:r,onOpenChange:i}=e,a=n!==void 0&&n,{t:o}=Me(),[s,c]=ke(Xi,!1),l=r!==void 0,u=l?r:a&&s!==!0,d;t[0]!==l||t[1]!==i||t[2]!==c?(d=()=>{l||c(!0),i?.(!1)},t[0]=l,t[1]=i,t[2]=c,t[3]=d):d=t[3];let f=Ae(d),p;t[4]!==f||t[5]!==i?(p=e=>{e?i?.(!0):f()},t[4]=f,t[5]=i,t[6]=p):p=t[6];let m;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(`div`,{className:`flex size-10 shrink-0 items-center justify-center rounded-xl bg-interactive-selection text-interactive-selection-foreground sm:size-12`,children:(0,$.jsx)(X,{name:`share-2`,className:`size-5`})}),t[7]=m):m=t[7];let h;t[8]===o?h=t[9]:(h=o(`assistants.shareWelcome.title`),t[8]=o,t[9]=h);let g;t[10]===h?g=t[11]:(g=(0,$.jsx)(Xt,{className:`typography-ui-header text-left sm:text-3xl`,children:h}),t[10]=h,t[11]=g);let _;t[12]===o?_=t[13]:(_=o(`assistants.shareWelcome.description`),t[12]=o,t[13]=_);let v;t[14]===_?v=t[15]:(v=(0,$.jsx)(Zt,{className:`typography-ui text-left leading-6 sm:max-w-3xl sm:text-base sm:leading-7`,children:_}),t[14]=_,t[15]=v);let y;t[16]!==g||t[17]!==v?(y=(0,$.jsxs)(qt,{className:`flex-row items-start gap-3 px-5 pb-5 pt-6 text-left sm:gap-4 sm:px-8 sm:pb-6 sm:pt-8`,children:[m,(0,$.jsxs)(`div`,{className:`min-w-0 space-y-1.5 sm:space-y-2`,children:[g,v]})]}),t[16]=g,t[17]=v,t[18]=y):y=t[18];let b;t[19]===o?b=t[20]:(b=o(`assistants.shareWelcome.examplesAria`),t[19]=o,t[20]=b);let x;t[21]===o?x=t[22]:(x=Zi.map((e,t)=>(0,$.jsxs)(`article`,{className:`w-[min(78vw,19rem)] shrink-0 snap-center overflow-hidden rounded-xl border border-border bg-background lg:w-auto lg:min-w-0`,children:[(0,$.jsxs)(`div`,{className:`relative overflow-hidden border-b border-border bg-muted`,children:[(0,$.jsx)(`img`,{src:e.image,alt:``,className:`h-72 w-full object-cover object-bottom lg:h-[min(38vh,23rem)]`}),(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`absolute left-3 top-3 flex size-7 items-center justify-center rounded-full bg-[var(--surface-elevated)] typography-meta font-semibold text-foreground shadow-sm`,children:t+1})]}),(0,$.jsxs)(`div`,{className:`space-y-1 px-4 py-3.5 lg:min-h-25`,children:[(0,$.jsx)(`h2`,{className:`typography-ui-label font-semibold text-foreground`,children:o(e.titleKey)}),(0,$.jsx)(`p`,{className:`typography-meta leading-5 text-muted-foreground`,children:o(e.descriptionKey)})]})]},e.titleKey)),t[21]=o,t[22]=x);let S;t[23]!==b||t[24]!==x?(S=(0,$.jsx)(`div`,{className:`overflow-hidden px-5 pb-5 sm:px-8 sm:pb-7`,children:(0,$.jsx)(`div`,{className:`flex snap-x snap-mandatory gap-3 overflow-x-auto pb-2 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden lg:grid lg:grid-cols-3 lg:overflow-visible lg:pb-0`,"aria-label":b,children:x})}),t[23]=b,t[24]=x,t[25]=S):S=t[25];let C;t[26]===o?C=t[27]:(C=o(`assistants.shareWelcome.action`),t[26]=o,t[27]=C);let w;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,$.jsx)(X,{name:`arrow-right-s`,className:`size-4`}),t[28]=w):w=t[28];let T;t[29]!==f||t[30]!==C?(T=(0,$.jsx)(Jt,{className:`border-t border-border px-5 py-4 sm:px-8 sm:py-5`,children:(0,$.jsxs)(J,{size:`lg`,className:`w-full lg:mx-auto lg:w-72`,onClick:f,children:[C,w]})}),t[29]=f,t[30]=C,t[31]=T):T=t[31];let E;t[32]!==S||t[33]!==T||t[34]!==y?(E=(0,$.jsxs)(Yt,{showCloseButton:!1,className:`w-[min(100%,31rem)] max-w-none gap-0 overflow-hidden rounded-2xl border-border bg-[var(--surface-elevated)] p-0 sm:w-[min(calc(100%-3rem),44rem)] lg:w-[min(calc(100%-4rem),74rem)]`,containerClassName:`fixed inset-0 z-50 flex items-end justify-center px-0 pt-8 sm:items-center sm:p-6`,children:[y,S,T]}),t[32]=S,t[33]=T,t[34]=y,t[35]=E):E=t[35];let D;return t[36]!==u||t[37]!==E||t[38]!==p?(D=(0,$.jsx)(Qt,{open:u,onOpenChange:p,children:E}),t[36]=u,t[37]=E,t[38]=p,t[39]=D):D=t[39],D},$i=`useCommandsStore`,ea=new Set([`init`,`review`]),ta=e=>ea.has(e.name),na=async(e,t)=>{await ct(w,e,t),i()===t&&ht(`commands`,{source:$i})},ra=oe()(ce(se(e=>({selectedCommandName:null,commandDraft:null,setSelectedCommand:t=>e({selectedCommandName:t}),setCommandDraft:t=>e({commandDraft:t}),loadCommands:async()=>{let e=zt(),t=i();try{return await ct(w,e,t),!0}catch{return!1}},createCommand:async t=>ia(`POST`,t.name,t,e),updateCommand:async(t,n)=>ia(`PATCH`,t,n,e),deleteCommand:async t=>ia(`DELETE`,t,void 0,e),getCommandByName:e=>rt().find(t=>t.name===e)}),{name:`commands-store`,storage:ge(),partialize:e=>({selectedCommandName:e.selectedCommandName})}),{name:`commands-store`}));async function ia(e,t,n,r){let a=zt(),o=i();try{let s={};if(e===`POST`&&(s.template=n?.template||``,n?.description&&(s.description=n.description),n?.agent&&(s.agent=n.agent),n?.model&&(s.model=n.model),n?.scope&&(s.scope=n.scope)),e===`PATCH`)for(let e of[`description`,`agent`,`model`,`template`])n?.[e]!==void 0&&(s[e]=n[e]);let c=a?`?directory=${encodeURIComponent(a)}`:``,u=await l(`/api/config/commands/${encodeURIComponent(t)}${c}`,{method:e,headers:e===`DELETE`?a?{"x-opencode-directory":a}:void 0:{"Content-Type":`application/json`,...a?{"x-opencode-directory":a}:{}},...e===`DELETE`?{}:{body:JSON.stringify(s)}}),d=await u.json().catch(()=>null);if(!u.ok)throw Error(d?.error||`Failed to ${e.toLowerCase()} command`);return i()!==o||(await na(a,o),i()!==o)||e===`DELETE`&&r({selectedCommandName:null}),!0}catch(e){return console.error(`[CommandsStore] Command mutation failed:`,e),!1}}typeof window<`u`&&(window.__zustand_commands_store__=ra),At(e=>{e.source!==$i&&Xe(e,`commands`)&&ra.getState().loadCommands()});var aa=()=>{try{let e=Ct.getState().getActiveProject?.();if(e?.path?.trim())return e.path.trim();let t=pe.getDirectory();if(t?.trim())return t.trim()}catch(e){console.warn(`[McpConfigStore] Error resolving config directory:`,e)}return null},oa=e=>e?Object.entries(e).map(([e,t])=>({key:e,value:t})):[],sa=e=>{let t=e.filter(e=>e.key.trim());if(t.length!==0)return Object.fromEntries(t.map(e=>[e.key.trim(),e.value]))},ca=e=>{if(typeof e==`string`)return e.trim()||void 0},la=oe()(ce(se((e,t)=>({selectedMcpName:null,mcpDraft:null,setSelectedMcp:t=>e({selectedMcpName:t}),setMcpDraft:t=>e({mcpDraft:t}),loadMcpConfigs:async e=>{let t=aa();try{return!e?.force&&wi(w,t).length>0||await yi(w,t,i()),!0}catch(e){return console.error(`[McpConfigStore] Failed to load MCP configs:`,e),!1}},createMcp:async(e,t)=>{let n=`directory`in(t??{})?t?.directory?.trim()||null:aa(),r=t?.transportIdentity??i();try{let t=ua(e),a=n?`?directory=${encodeURIComponent(n)}`:``,o=await l(`/api/config/mcp/${encodeURIComponent(e.name)}${a}`,{method:`POST`,headers:{"Content-Type":`application/json`,...n?{"x-opencode-directory":n}:{}},body:JSON.stringify(t)}),s=await o.json().catch(()=>null);if(!o.ok)throw Error(s?.error||`Failed to create MCP server`);return i()===r?(await yi(w,n,r),await Ci(w,n,r),{ok:!0,reloadFailed:s?.reloadFailed===!0,message:s?.message,warning:s?.warning}):{ok:!0}}catch(e){return console.error(`[McpConfigStore] Failed to create MCP:`,e),{ok:!1}}},updateMcp:async(e,t,n)=>{let r=`directory`in(n??{})?n?.directory?.trim()||null:aa(),a=n?.transportIdentity??i();try{let n=ua(t),o=r?`?directory=${encodeURIComponent(r)}`:``,s=await l(`/api/config/mcp/${encodeURIComponent(e)}${o}`,{method:`PATCH`,headers:{"Content-Type":`application/json`,...r?{"x-opencode-directory":r}:{}},body:JSON.stringify(n)}),c=await s.json().catch(()=>null);if(!s.ok)throw Error(c?.error||`Failed to update MCP server`);return i()===a?(await yi(w,r,a),await Ci(w,r,a),{ok:!0,reloadFailed:c?.reloadFailed===!0,message:c?.message,warning:c?.warning}):{ok:!0}}catch(e){throw console.error(`[McpConfigStore] Failed to update MCP:`,e),e}},deleteMcp:async(n,r)=>{let a=`directory`in(r??{})?r?.directory?.trim()||null:aa(),o=r?.transportIdentity??i();try{let r=a?`?directory=${encodeURIComponent(a)}`:``,s=await l(`/api/config/mcp/${encodeURIComponent(n)}${r}`,{method:`DELETE`,headers:a?{"x-opencode-directory":a}:void 0}),c=await s.json().catch(()=>null);if(!s.ok)throw Error(c?.error||`Failed to delete MCP server`);return pi.getState().clearDiagnostic(n,a,o),i()===o?(t().selectedMcpName===n&&e({selectedMcpName:null}),await yi(w,a,o),await Ci(w,a,o),{ok:!0,reloadFailed:c?.reloadFailed===!0,message:c?.message,warning:c?.warning}):{ok:!0}}catch(e){return console.error(`[McpConfigStore] Failed to delete MCP:`,e),{ok:!1}}}}),{name:`mcp-config-store`,storage:ge(),partialize:e=>({selectedMcpName:e.selectedMcpName})}),{name:`mcp-config-store`}));function ua(e){let t={};if(e.scope!==void 0&&(t.scope=e.scope),e.type!==void 0&&(t.type=e.type),(e.type===`local`||e.command!==void 0)&&(t.command=(e.command??[]).filter(e=>e.trim())),(e.type===`remote`||e.url!==void 0)&&(t.url=e.url?.trim()??``),e.environment!==void 0&&(t.environment=sa(e.environment)??{}),e.headers!==void 0&&(t.headers=sa(e.headers)??{}),e.oauthEnabled!==void 0||e.oauthClientId!==void 0||e.oauthClientSecret!==void 0||e.oauthScope!==void 0||e.oauthRedirectUri!==void 0)if(e.oauthEnabled===!1)t.oauth=!1;else{let n={clientId:ca(e.oauthClientId),clientSecret:ca(e.oauthClientSecret),scope:ca(e.oauthScope),redirectUri:ca(e.oauthRedirectUri)};t.oauth=n.clientId||n.clientSecret||n.scope||n.redirectUri?n:e.oauthEnabled?{}:!1}if(e.timeout!==void 0){let n=Number(e.timeout);t.timeout=Number.isFinite(n)&&n>0?n:null}return e.enabled!==void 0&&(t.enabled=e.enabled),t}var da=()=>{let e=pe.getDirectory();if(typeof e==`string`&&e.trim().length>0)return e;try{let e=window.__zustand_directory_store__;if(e)return e.getState().currentDirectory}catch{}return null},fa=`useSkillsStore`,pa=e=>{if(e&&Object.prototype.hasOwnProperty.call(e,`directory`))return typeof e.directory==`string`&&e.directory.trim()||null;let t=da();return typeof t==`string`&&t.trim()||null},ma=oe()(ce(se((e,t)=>({selectedSkillName:null,skillDraft:null,setSelectedSkill:t=>{e({selectedSkillName:t})},setSkillDraft:t=>{e({skillDraft:t})},loadSkills:async()=>{try{return await Nt(w,da(),i()),!0}catch{return!1}},getSkillDetail:async e=>{try{let t=da(),n=t?`?directory=${encodeURIComponent(t)}`:``,r=await l(`/api/config/skills/${encodeURIComponent(e)}${n}`);return r.ok?await r.json():null}catch{return null}},createSkill:async(e,t)=>{try{let n={name:e.name,description:e.description};e.instructions&&(n.instructions=e.instructions),e.scope&&(n.scope=e.scope),e.source&&(n.source=e.source),e.supportingFiles&&(n.supportingFiles=e.supportingFiles);let r=pa(t),a=i(),o=r?`?directory=${encodeURIComponent(r)}`:``,s=await l(`/api/config/skills/${encodeURIComponent(e.name)}${o}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(n)}),c=await s.json().catch(()=>null);if(!s.ok){let e=c?.error||`Failed to create skill`;throw Error(e)}return await ha({directory:r,transportIdentity:a}),!0}catch{return!1}},updateSkill:async(e,t,n)=>{try{let r={};t.description!==void 0&&(r.description=t.description),t.instructions!==void 0&&(r.instructions=t.instructions),t.supportingFiles!==void 0&&(r.supportingFiles=t.supportingFiles),t.targetPath!==void 0&&(r.targetPath=t.targetPath);let a=pa(n),o=i(),s=a?`?directory=${encodeURIComponent(a)}`:``,c=await l(`/api/config/skills/${encodeURIComponent(e)}${s}`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify(r)}),u=await c.json().catch(()=>null);if(!c.ok){let e=u?.error||`Failed to update skill`;throw Error(e)}return await ha({directory:a,transportIdentity:o}),!0}catch{return!1}},deleteSkill:async(n,r)=>{try{let a=pa(r),o=i(),s=a?`?directory=${encodeURIComponent(a)}`:``,c=await l(`/api/config/skills/${encodeURIComponent(n)}${s}`,{method:`DELETE`}),u=await c.json().catch(()=>null);if(!c.ok){let e=u?.error||`Failed to delete skill`;throw Error(e)}return await ha({directory:a,transportIdentity:o}),i()===o&&t().selectedSkillName===n&&e({selectedSkillName:null}),!0}catch{return!1}},getSkillByName:e=>Qe(w,da()).find(t=>t.name===e),readSupportingFile:async(e,t)=>{try{let n=da(),r=n?`&directory=${encodeURIComponent(n)}`:``,i=await l(`/api/config/skills/${encodeURIComponent(e)}/files/${encodeURIComponent(t)}?${r.slice(1)}`);return i.ok?(await i.json()).content??null:null}catch{return null}},writeSupportingFile:async(e,t,n)=>{try{let r=da(),i=r?`?directory=${encodeURIComponent(r)}`:``;return(await l(`/api/config/skills/${encodeURIComponent(e)}/files/${encodeURIComponent(t)}${i}`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({content:n})})).ok}catch{return!1}},deleteSupportingFile:async(e,t)=>{try{let n=da(),r=n?`?directory=${encodeURIComponent(n)}`:``;return(await l(`/api/config/skills/${encodeURIComponent(e)}/files/${encodeURIComponent(t)}${r}`,{method:`DELETE`})).ok}catch{return!1}}}),{name:`skills-store`,storage:ge(),partialize:e=>({selectedSkillName:e.selectedSkillName})}),{name:`skills-store`}));typeof window<`u`&&(window.__zustand_skills_store__=ma);async function ha(e){let t=e&&`directory`in e?e.directory?.trim()||null:da(),n=e?.transportIdentity??i();i()===n&&(await Nt(w,t,n),i()===n&&(await at(w,t,n),i()===n&&ht(`skills`,{source:fa})))}var ga=null;ga||=At(e=>{if(e.source!==fa&&Xe(e,`skills`)){let e=da(),t=i();Nt(w,e,t).then(()=>at(w,e,t)).catch(()=>void 0)}});var _a=/^#[0-9a-fA-F]{6}$/,va=/^\{file:.+\}$/i,ya=e=>[...e].sort((e,t)=>{let n=e.permission.localeCompare(t.permission);return n===0?e.pattern.localeCompare(t.pattern):n}),ba=(e,t)=>{let n=ya(e),r=ya(t);return n.length===r.length&&n.every((e,t)=>{let n=r[t];return e.permission===n.permission&&e.pattern===n.pattern&&e.action===n.action})},xa=(e,t)=>t?e.globalPermission!==t.globalPermission||!ba(e.permissionRules,t.permissionRules):!1,Sa=e=>e===`bash`?`shell`:e===`task`?`subagent`:e===`write`||e===`patch`?`edit`:e,Ca=(e,t)=>{let n=[{action:`*`,resource:`*`,effect:e}];for(let e of t)!e.permission||!e.pattern||(e.permission!==`*`||e.pattern!==`*`)&&n.push({action:Sa(e.permission),resource:e.pattern,effect:e.action});return n},wa=e=>{let t=e.trim();return t===``?null:t},Ta=({isNewAgent:e,agentName:t,draftScope:n,initialScope:r,draftHasExplicitPermission:i,current:a,initial:o,confirmDrop:s})=>{let c=Ca(a.globalPermission,a.permissionRules);if(e){let e=a.description.trim(),r=wa(a.model),l=a.system.trim(),u=xa(a,o)||i;return{name:t,mode:a.mode,...e?{description:e}:{},...r?{model:r}:{},...l?{system:l}:{},...u?{permissions:c}:{},...n?{scope:n}:{},...s?{confirmDrop:!0}:{}}}let l={name:t,...s?{confirmDrop:!0}:{}};return o?(a.description!==o.description&&(l.description=a.description.trim()||null),a.mode!==o.mode&&(l.mode=a.mode),a.model!==o.model&&(l.model=wa(a.model)),a.system!==o.system&&(l.system=a.system.trim()||null),xa(a,o)&&(l.permissions=c),n&&r&&n!==r&&(l.scope=n),l):l},Ea=e=>{if(e){if(typeof e.prompt==`string`)return va.test(e.prompt.trim())?void 0:e.prompt;if(typeof e.system==`string`)return e.system}},Da=e=>{let t=e?.model?.providerID,n=e?.model?.modelID||e?.model?.id;if(!t||!n)return``;let r=e?.model?.variant||e?.variant;return r?`${t}/${n}#${r}`:`${t}/${n}`},Oa=e=>{let t=e.trim(),n=t.indexOf(`/`);if(n<=0||n>=t.length-1)return null;let r=t.slice(0,n),i=t.slice(n+1),a=i.indexOf(`#`);return a===-1?{providerId:r,modelId:i,variant:``}:{providerId:r,modelId:i.slice(0,a),variant:i.slice(a+1)}},ka=e=>_a.test(e.trim()),Aa=e=>{let t=e.trim();return t&&t.charAt(0).toUpperCase()+t.slice(1)},ja=e=>{let t=(0,Ii.c)(37),{className:n}=e,{t:r}=Me(),i=Ct(Ma),a=Ct(Na),o=Ct(Pa),s=k(),c;t[0]===i?c=t[1]:(c=[...i].sort(Fa),t[0]=i,t[1]=c);let l=c,u;bb0:{if(l.length===0){u=null;break bb0}let e;t[2]!==a||t[3]!==l?(e=l.find(e=>e.id===a)??l[0],t[2]=a,t[3]=l,t[4]=e):e=t[4],u=e}let d=u;if(s||l.length===0)return null;let f;t[5]!==d?.path||t[6]!==r?(f=d?.path.split(`/`).filter(Boolean).pop()||d?.path||r(`settings.shared.projectSelector.fallbackProject`),t[5]=d?.path,t[6]=r,t[7]=f):f=t[7];let p=f,m;t[8]===n?m=t[9]:(m=q(n),t[8]=n,t[9]=m);let h;t[10]===r?h=t[11]:(h=r(`settings.shared.projectSelector.switchProjectAria`),t[10]=r,t[11]=h);let g;t[12]===r?g=t[13]:(g=r(`settings.shared.projectSelector.switchProjectTitle`),t[12]=r,t[13]=g);let _,v;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(_=q(`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`),v=(0,$.jsx)(X,{name:`folder`,className:`h-4 w-4 text-muted-foreground`}),t[14]=_,t[15]=v):(_=t[14],v=t[15]);let y;t[16]===p?y=t[17]:(y=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate typography-ui-label font-medium`,children:p}),t[16]=p,t[17]=y);let b;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,$.jsx)(X,{name:`arrow-down-s`,className:`size-4 opacity-50`}),t[18]=b):b=t[18];let x;t[19]!==h||t[20]!==g||t[21]!==y?(x=(0,$.jsx)(mr,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,"aria-label":h,title:g,className:_,children:[v,y,b]})}),t[19]=h,t[20]=g,t[21]=y,t[22]=x):x=t[22];let S=d?.id??``,C;t[23]===o?C=t[24]:(C=e=>{e&&o(e)},t[23]=o,t[24]=C);let w;t[25]===l?w=t[26]:(w=l.map(Ia),t[25]=l,t[26]=w);let T;t[27]!==S||t[28]!==C||t[29]!==w?(T=(0,$.jsx)(Qn,{align:`start`,className:`w-auto`,children:(0,$.jsx)(lr,{value:S,onValueChange:C,children:w})}),t[27]=S,t[28]=C,t[29]=w,t[30]=T):T=t[30];let E;t[31]!==x||t[32]!==T?(E=(0,$.jsxs)(cr,{children:[x,T]}),t[31]=x,t[32]=T,t[33]=E):E=t[33];let D;return t[34]!==E||t[35]!==m?(D=(0,$.jsx)(`div`,{className:m,children:E}),t[34]=E,t[35]=m,t[36]=D):D=t[36],D};function Ma(e){return e.projects}function Na(e){return e.activeProjectId}function Pa(e){return e.setActiveProject}function Fa(e,t){return(e.label||e.path).localeCompare(t.label||t.path)}function Ia(e){let t=e.path.split(`/`).filter(Boolean).pop()||e.path;return(0,$.jsx)(Kn,{value:e.id,children:(0,$.jsx)(`span`,{className:`min-w-0 truncate typography-ui`,children:t})},e.id)}function La(e,t){return`opencode:sidebar-group:${e}:${t}`}var Ra=e=>{let t=(0,Ii.c)(57),{label:n,count:r,storageKey:i,defaultExpanded:a,variant:o,labelPrefix:s,children:c}=e,l=a===void 0||a,u=o===void 0?`sidebar`:o,d;t[0]!==n||t[1]!==i?(d=La(i,n),t[0]=n,t[1]=i,t[2]=d):d=t[2];let f=d,p=Q.useId(),m;t[3]!==l||t[4]!==f?(m=()=>{try{let e=localStorage.getItem(f);if(e!==null)return e===`true`}catch{}return l},t[3]=l,t[4]=f,t[5]=m):m=t[5];let[h,g]=(0,Q.useState)(m),_,v;if(t[6]!==h||t[7]!==f?(_=()=>{try{localStorage.setItem(f,String(h))}catch{}},v=[f,h],t[6]=h,t[7]=f,t[8]=_,t[9]=v):(_=t[8],v=t[9]),(0,Q.useEffect)(_,v),u===`settings-card`){let e;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(e=()=>g(za),t[10]=e):e=t[10];let i;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(i=q(`flex w-full items-center gap-1 text-left`,`text-inherit transition-colors duration-150 hover:text-foreground`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`),t[11]=i):i=t[11];let a=!h&&`-rotate-90`,o;t[12]===a?o=t[13]:(o=q(`h-3.5 w-3.5 flex-shrink-0 transition-transform duration-200`,a),t[12]=a,t[13]=o);let l;t[14]===o?l=t[15]:(l=(0,$.jsx)(X,{name:`arrow-down-s`,className:o}),t[14]=o,t[15]=l);let u=s?`${s} · `:``,d;t[16]!==n||t[17]!==u?(d=(0,$.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[u,n]}),t[16]=n,t[17]=u,t[18]=d):d=t[18];let f;t[19]===r?f=t[20]:(f=(0,$.jsx)(`span`,{className:`ml-1 tabular-nums opacity-60`,children:r}),t[19]=r,t[20]=f);let m;t[21]!==p||t[22]!==h||t[23]!==l||t[24]!==d||t[25]!==f?(m=(0,$.jsxs)(`button`,{type:`button`,onClick:e,"aria-expanded":h,"aria-controls":p,className:i,children:[l,d,f]}),t[21]=p,t[22]=h,t[23]=l,t[24]=d,t[25]=f,t[26]=m):m=t[26];let _=!h&&`hidden`,v;t[27]===_?v=t[28]:(v=q(_),t[27]=_,t[28]=v);let y;return t[29]!==c||t[30]!==p||t[31]!==m||t[32]!==v?(y=(0,$.jsx)(vi,{label:m,cardClassName:v,cardId:p,children:c}),t[29]=c,t[30]=p,t[31]=m,t[32]=v,t[33]=y):y=t[33],y}let y;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(y=()=>g(Ba),t[34]=y):y=t[34];let b;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(b=q(`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`),t[35]=b):b=t[35];let x=!h&&`-rotate-90`,S;t[36]===x?S=t[37]:(S=q(`h-3.5 w-3.5 flex-shrink-0 transition-transform duration-200`,x),t[36]=x,t[37]=S);let C;t[38]===S?C=t[39]:(C=(0,$.jsx)(X,{name:`arrow-down-s`,className:S}),t[38]=S,t[39]=C);let w;t[40]===n?w=t[41]:(w=(0,$.jsx)(`span`,{className:`flex-1 truncate`,children:n}),t[40]=n,t[41]=w);let T;t[42]===r?T=t[43]:(T=(0,$.jsx)(`span`,{className:`ml-1 tabular-nums opacity-60`,children:r}),t[42]=r,t[43]=T);let E;t[44]!==p||t[45]!==h||t[46]!==C||t[47]!==w||t[48]!==T?(E=(0,$.jsxs)(`button`,{type:`button`,onClick:y,"aria-expanded":h,"aria-controls":p,className:b,children:[C,w,T]}),t[44]=p,t[45]=h,t[46]=C,t[47]=w,t[48]=T,t[49]=E):E=t[49];let D=!h,O;t[50]!==c||t[51]!==p||t[52]!==D?(O=(0,$.jsx)(`div`,{id:p,hidden:D,className:`mt-0.5 space-y-0.5 ml-2 pl-3 border-l-2 border-[var(--interactive-border)]`,children:c}),t[50]=c,t[51]=p,t[52]=D,t[53]=O):O=t[53];let k;return t[54]!==E||t[55]!==O?(k=(0,$.jsxs)(`div`,{children:[E,O]}),t[54]=E,t[55]=O,t[56]=k):k=t[56],k};function za(e){return!e}function Ba(e){return!e}var Va=e=>e===`bash`?`shell`:e===`task`?`subagent`:e===`write`||e===`patch`?`edit`:e,Ha=e=>{let t=gr(e).map(e=>({action:Va(e.action),resource:e.resource,effect:e.effect}));return t.length>0?t:void 0},Ua=(e,t)=>{let n=e,r=Wt(e)?void 0:typeof n.system==`string`?n.system:typeof e.prompt==`string`?e.prompt:void 0,i=typeof n.color==`string`&&ka(n.color)?n.color:void 0;return{name:t,scope:n.scope||`user`,description:e.description,model:Da(e)||null,...r?{system:r}:{},mode:e.mode,...typeof n.steps==`number`?{steps:n.steps}:{},...e.hidden===!0?{hidden:!0}:{},...n.disabledOverride?{disabled:!0}:{},...i?{color:i}:{},permissions:Ha(n.permissions??e.permission)}},Wa=({onItemSelect:e})=>{let{t}=Me(),[n,r]=Q.useState(null),[i,a]=Q.useState(``),[o,s]=Q.useState(null),[c,l]=Q.useState(null),[u,d]=Q.useState(!1),[f,p]=Q.useState(null),{selectedAgentName:m,setSelectedAgent:h,setAgentDraft:g,createAgent:_,deleteAgent:v,loadAgents:y}=Pt(le(e=>({selectedAgentName:e.selectedAgentName,setSelectedAgent:e.setSelectedAgent,setAgentDraft:e.setAgentDraft,createAgent:e.createAgent,deleteAgent:e.deleteAgent,loadAgents:e.loadAgents}))),{data:b=[]}=bt();Q.useEffect(()=>{y()},[y]);let x=()=>{let t=`new-agent`,n=t,r=1;for(;b.some(e=>e.name===n);)n=`${t}-${r}`,r++;g({name:n,scope:`user`}),h(n),e?.()},S=async e=>{if(Wt(e)){Y.error(t(`settings.agents.sidebar.toast.builtInCannotDelete`));return}s(e),l(`delete`)},C=async e=>{Wt(e)&&(s(e),l(`reset`))},w=()=>{s(null),l(null)},T=async()=>{if(!(!o||!c)){d(!0);try{let e=await v(o.name,o.scope);e.ok?(e.requiresManualRestart?Y.warning(t(`settings.agents.page.toast.savedManualRestart`)):c===`delete`?Y.success(t(`settings.agents.sidebar.toast.agentDeleted`,{name:o.name})):Y.success(t(`settings.agents.sidebar.toast.agentReset`,{name:o.name})),w()):c===`delete`?Y.error(t(`settings.agents.sidebar.toast.deleteFailed`)):Y.error(t(`settings.agents.sidebar.toast.resetFailed`))}catch(e){let n=e instanceof Error?e.message:``,r=/built-in|not deletable|not found/i.test(n);c===`delete`?Y.error(t(r?`settings.agents.sidebar.toast.definitionNotFound`:`settings.agents.sidebar.toast.deleteFailed`)):Y.error(t(`settings.agents.sidebar.toast.resetFailed`))}d(!1)}},E=e=>{let t=e.name,n=1,r=`${t}-copy`;for(;b.some(e=>e.name===r);)n++,r=`${t}-copy-${n}`;g(Ua(e,r)),h(r)},D=e=>{a(e.name),r(e)},O=async()=>{if(!n)return;let e=i.trim().replace(/\s+/g,`-`);if(!e){Y.error(t(`settings.agents.sidebar.toast.agentNameRequired`));return}if(e===n.name){r(null);return}if(b.some(t=>t.name===e)){Y.error(t(`settings.agents.sidebar.toast.agentExists`));return}let a=n,o=await _({...Ua(n,e),scope:a.scope});if(o.ok){let r=await v(n.name,a.scope);r.ok?(o.requiresManualRestart||r.requiresManualRestart?Y.warning(t(`settings.agents.page.toast.savedManualRestart`)):Y.success(t(`settings.agents.sidebar.toast.agentRenamed`,{name:e})),h(e)):Y.error(t(`settings.agents.sidebar.toast.removeOldAfterRenameFailed`))}else Y.error(t(`settings.agents.sidebar.toast.renameFailed`));r(null)},k=e=>{switch(e){case`primary`:return(0,$.jsx)(X,{name:`ai-agent`,className:`h-3 w-3 text-primary`});case`all`:return(0,$.jsx)(X,{name:`ai-agent-fill`,className:`h-3 w-3 text-primary`});case`subagent`:return(0,$.jsx)(X,{name:`robot`,className:`h-3 w-3 text-primary`});default:return null}},A=b.filter(e=>{let t=e;return!yt(e)||!!t.scope||t.disabledOverride===!0}),j=A.filter(Wt),M=A.filter(e=>!Wt(e)),{groupedCustomAgents:N,ungroupedCustomAgents:P}=(0,Q.useMemo)(()=>{let e={},t=[];for(let n of M){let r=n;r.group?(e[r.group]||(e[r.group]=[]),e[r.group].push(n)):t.push(n)}return{groupedCustomAgents:Object.keys(e).sort((e,t)=>e.localeCompare(t)).map(t=>({name:t,agents:e[t]})),ungroupedCustomAgents:t}},[M]),F=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,$.jsx)(`span`,{children:t(`settings.agents.sidebar.section.custom`)}),(0,$.jsx)(J,{"data-settings-item":`agents.create`,size:`icon`,variant:`ghost`,onClick:x,"aria-label":t(`settings.agents.page.title.new`),children:(0,$.jsx)(X,{name:`add`,className:`h-4 w-4`})})]});return(0,$.jsxs)(`div`,{className:`oc-settings-page-content h-full overflow-y-auto bg-background p-3`,children:[(0,$.jsx)(ja,{}),(0,$.jsx)($.Fragment,{children:A.length===0?(0,$.jsx)(vi,{children:(0,$.jsxs)(`div`,{className:`oc-settings-group-row py-12 text-center text-muted-foreground`,children:[(0,$.jsx)(X,{name:`robot-2`,className:`mx-auto mb-3 h-10 w-10 opacity-50`}),(0,$.jsx)(`p`,{className:`typography-ui-label font-medium`,children:t(`settings.agents.sidebar.empty.title`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 opacity-75`,children:t(`settings.agents.sidebar.empty.description`)})]})}):(0,$.jsxs)($.Fragment,{children:[j.length>0&&(0,$.jsx)(vi,{label:t(`settings.agents.sidebar.section.builtIn`),children:j.map(t=>(0,$.jsx)(Ga,{agent:t,isSelected:m===t.name,onSelect:()=>{h(t.name),e?.()},onReset:()=>C(t),onDuplicate:()=>E(t),getAgentModeIcon:k,isMenuOpen:f===t.name,onMenuOpenChange:e=>p(e?t.name:null)},t.name))}),M.length>0&&(0,$.jsxs)($.Fragment,{children:[N.map(({name:n,agents:r})=>(0,$.jsx)(Ra,{label:n,count:r.length,storageKey:`agents`,variant:`settings-card`,labelPrefix:t(`settings.agents.sidebar.section.custom`),children:r.map(t=>(0,$.jsx)(Ga,{agent:t,isSelected:m===t.name,onSelect:()=>{h(t.name),e?.()},onRename:()=>D(t),onDelete:()=>S(t),onDuplicate:()=>E(t),getAgentModeIcon:k,isMenuOpen:f===t.name,onMenuOpenChange:e=>p(e?t.name:null)},t.name))},n)),P.length>0?(0,$.jsx)(vi,{label:F,children:P.map(t=>(0,$.jsx)(Ga,{agent:t,isSelected:m===t.name,onSelect:()=>{h(t.name),e?.()},onRename:()=>D(t),onDelete:()=>S(t),onDuplicate:()=>E(t),getAgentModeIcon:k,isMenuOpen:f===t.name,onMenuOpenChange:e=>p(e?t.name:null)},t.name))}):(0,$.jsx)(vi,{label:F,cardClassName:`hidden`,children:(0,$.jsx)(`span`,{})})]}),M.length===0&&(0,$.jsx)(vi,{label:F,cardClassName:`hidden`,children:(0,$.jsx)(`span`,{})})]})}),(0,$.jsx)(Qt,{open:o!==null&&c!==null,onOpenChange:e=>{!e&&!u&&w()},children:(0,$.jsxs)(Yt,{className:`max-w-md`,children:[(0,$.jsxs)(qt,{children:[(0,$.jsx)(Xt,{children:t(c===`delete`?`settings.agents.sidebar.dialog.deleteTitle`:`settings.agents.sidebar.dialog.resetTitle`)}),(0,$.jsx)(Zt,{children:t(c===`delete`?`settings.agents.sidebar.dialog.deleteDescription`:`settings.agents.sidebar.dialog.resetDescription`,{name:o?.name??``})})]}),(0,$.jsxs)(Jt,{children:[(0,$.jsx)(J,{size:`sm`,variant:`ghost`,onClick:w,disabled:u,children:t(`settings.common.actions.cancel`)}),(0,$.jsx)(J,{size:`sm`,onClick:T,disabled:u,children:t(c===`delete`?`settings.common.actions.delete`:`settings.common.actions.reset`)})]})]})}),(0,$.jsx)(Qt,{open:n!==null,onOpenChange:e=>!e&&r(null),children:(0,$.jsxs)(Yt,{children:[(0,$.jsxs)(qt,{children:[(0,$.jsx)(Xt,{children:t(`settings.agents.sidebar.renameDialog.title`)}),(0,$.jsx)(Zt,{children:t(`settings.agents.sidebar.renameDialog.description`,{name:n?.name??``})})]}),(0,$.jsx)(fn,{value:i,onChange:e=>a(e.target.value),placeholder:t(`settings.agents.sidebar.renameDialog.placeholder`),className:`text-foreground placeholder:text-muted-foreground`,onKeyDown:e=>{e.key===`Enter`&&O()}}),(0,$.jsxs)(Jt,{children:[(0,$.jsx)(J,{size:`sm`,variant:`ghost`,onClick:()=>r(null),children:t(`settings.common.actions.cancel`)}),(0,$.jsx)(J,{size:`sm`,onClick:O,children:t(`settings.common.actions.rename`)})]})]})})]})},Ga=e=>{let t=(0,Ii.c)(55),{agent:n,isSelected:r,onSelect:i,onDelete:a,onReset:o,onRename:s,onDuplicate:c,getAgentModeIcon:l,isMenuOpen:u,onMenuOpenChange:d}=e,{t:f}=Me(),p=n,m;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(m=br(),t[0]=m):m=t[0];let h=m,[g,_]=Q.useState(!1),v;t[1]!==a||t[2]!==c||t[3]!==s||t[4]!==o||t[5]!==f?(v=e=>(0,$.jsxs)($.Fragment,{children:[s&&(0,$.jsxs)(e,{onClick:e=>{e.stopPropagation(),s()},children:[(0,$.jsx)(X,{name:`edit`,className:`h-4 w-4 mr-px`}),f(`settings.common.actions.rename`)]}),(0,$.jsxs)(e,{onClick:e=>{e.stopPropagation(),c()},children:[(0,$.jsx)(X,{name:`file-copy`,className:`h-4 w-4 mr-px`}),f(`settings.common.actions.duplicate`)]}),o&&(0,$.jsxs)(e,{onClick:e=>{e.stopPropagation(),o()},children:[(0,$.jsx)(X,{name:`restart`,className:`h-4 w-4 mr-px`}),f(`settings.common.actions.reset`)]}),a&&(0,$.jsxs)(e,{onClick:e=>{e.stopPropagation(),a()},className:`text-destructive focus:text-destructive`,children:[(0,$.jsx)(X,{name:`delete-bin`,className:`h-4 w-4 mr-px`}),f(`settings.common.actions.delete`)]})]}),t[1]=a,t[2]=c,t[3]=s,t[4]=o,t[5]=f,t[6]=v):v=t[6];let y=v,b=r?`bg-interactive-selection`:`hover:bg-interactive-hover`,x;t[7]===b?x=t[8]:(x=q(`oc-settings-group-row group relative flex items-center transition-colors duration-150 select-none`,b),t[7]=b,t[8]=x);let S;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(S=h?void 0:e=>{e.preventDefault(),_(!0)},t[9]=S):S=t[9];let C;t[10]===x?C=t[11]:(C=(0,$.jsx)(`div`,{className:x,onContextMenu:S}),t[10]=x,t[11]=C);let w;t[12]===n.name?w=t[13]:(w=Aa(n.name),t[12]=n.name,t[13]=w);let T;t[14]===w?T=t[15]:(T=(0,$.jsx)(`span`,{className:`typography-ui-label font-normal truncate text-foreground`,children:w}),t[14]=w,t[15]=T);let E;t[16]!==n.mode||t[17]!==l?(E=l(n.mode),t[16]=n.mode,t[17]=l,t[18]=E):E=t[18];let D;t[19]!==n||t[20]!==p.disabledOverride||t[21]!==p.scope||t[22]!==f?(D=(p.scope||Wt(n)||p.disabledOverride)&&(0,$.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:p.disabledOverride?f(`settings.agents.sidebar.badge.disabled`):Wt(n)?f(`settings.agents.sidebar.badge.system`):p.scope===`project`?f(`settings.common.scope.project`):f(`settings.common.scope.global`)}),t[19]=n,t[20]=p.disabledOverride,t[21]=p.scope,t[22]=f,t[23]=D):D=t[23];let O;t[24]!==D||t[25]!==T||t[26]!==E?(O=(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[T,E,D]}),t[24]=D,t[25]=T,t[26]=E,t[27]=O):O=t[27];let k;t[28]===n.description?k=t[29]:(k=n.description&&(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground/60 truncate leading-tight`,children:n.description}),t[28]=n.description,t[29]=k);let A;t[30]!==i||t[31]!==O||t[32]!==k?(A=(0,$.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:[O,k]}),t[30]=i,t[31]=O,t[32]=k,t[33]=A):A=t[33];let j;t[34]===d?j=t[35]:(j=e=>{e&&_(!1),d(e)},t[34]=d,t[35]=j);let M;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,$.jsx)(mr,{asChild:!0,children:(0,$.jsx)(J,{size:`sm`,variant:`ghost`,className:`h-6 w-6 px-0 flex-shrink-0 -mr-1 opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100`,children:(0,$.jsx)(X,{name:`more-2`,className:`h-3.5 w-3.5`})})}),t[36]=M):M=t[36];let N;t[37]===y?N=t[38]:(N=(0,$.jsx)(Qn,{align:`end`,className:`w-fit min-w-20`,children:y(Wn)}),t[37]=y,t[38]=N);let P;t[39]!==u||t[40]!==j||t[41]!==N?(P=(0,$.jsxs)(cr,{open:u,onOpenChange:j,children:[M,N]}),t[39]=u,t[40]=j,t[41]=N,t[42]=P):P=t[42];let F;t[43]!==A||t[44]!==P?(F=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center`,children:[A,P]}),t[43]=A,t[44]=P,t[45]=F):F=t[45];let I;t[46]!==F||t[47]!==C?(I=(0,$.jsx)(Ei,{render:C,children:F}),t[46]=F,t[47]=C,t[48]=I):I=t[48];let L;t[49]===y?L=t[50]:(L=(0,$.jsx)(Di,{className:`w-fit min-w-20`,children:y(Oi)}),t[49]=y,t[50]=L);let R;return t[51]!==g||t[52]!==I||t[53]!==L?(R=(0,$.jsxs)(ki,{open:g,onOpenChange:_,children:[I,L]}),t[51]=g,t[52]=I,t[53]=L,t[54]=R):R=t[54],R};function Ka(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function qa(e){return typeof e==`string`&&e.length>0?e:void 0}function Ja(e){let t=Ka(e)?e:null,n=t&&Array.isArray(t.data)?t.data:Array.isArray(e)?e:null;if(!n)throw Error(`permission saved: expected list payload`);return n.map(e=>{if(!Ka(e))throw Error(`permission saved: invalid rule`);let t=qa(e.id),n=qa(e.projectID),r=qa(e.action),i=qa(e.resource);if(!t||!n||!r||!i)throw Error(`permission saved: invalid rule`);return{id:t,projectID:n,action:r,resource:i}})}async function Ya(e,t){if(!e.trim())throw Error(`permission saved: directory required`);t?.throwIfAborted();let n=await pe.getApiClient().location.get({location:{directory:e}},{signal:t});t?.throwIfAborted();let r=qa(n?.project?.id);if(!r)throw Error(`permission saved: project ID required`);return r}async function Xa(e){e.signal?.throwIfAborted();let t=await pe.getApiClient().permission.saved.list({projectID:e.projectID??void 0},{signal:e.signal});e.signal?.throwIfAborted();let n=Ja(t);if(e.projectID&&n.some(t=>t.projectID!==e.projectID))throw Error(`permission saved: project mismatch`);return n}async function Za(e){e.signal?.throwIfAborted(),await pe.getApiClient().permission.saved.remove({id:e.id},{signal:e.signal})}function Qa(e){if(e.transport!==i()||e.generation!==o())throw Error(`Saved permission runtime changed`)}var $a=e=>Te({queryKey:[e.transport,e.generation,`saved-permission-project`,e.directory],queryFn:async({signal:t})=>{Qa(e);let n=await Ya(e.directory,t);return Qa(e),n},retry:!1}),eo=e=>Te({queryKey:[e.transport,e.generation,`saved-permissions`,e.directory,e.projectID],queryFn:async({signal:t})=>{if(Qa(e),!e.directory||!e.projectID)throw Error(`Saved permission scope required`);let n=await Xa({projectID:e.projectID,signal:t});return Qa(e),n},retry:!1});function to(e){let t=(0,Ii.c)(3),n=(0,Q.useSyncExternalStore)(r,o,o),a={transport:i(),generation:n,directory:e.trim()},s=Ee({...$a(a),enabled:!!a.directory}),c={...a,projectID:s.data??``},l=eo(c),u=!!(a.directory&&s.data)&&!s.isError,d;return t[0]!==l||t[1]!==u?(d={...l,enabled:u},t[0]=l,t[1]=u,t[2]=d):d=t[2],{project:s,list:Ee(d),scope:c}}async function no(e,t,n){Qa(t);let r=eo(t).queryKey;if(!e.getQueryData(r)?.some(e=>e.id===n&&e.projectID===t.projectID))throw Error(`Saved permission is outside the captured scope`);await Za({id:n}),t.transport===i()&&t.generation===o()&&(await e.cancelQueries({queryKey:r,exact:!0}),t.transport===i()&&t.generation===o()&&e.setQueryData(r,e=>e?.filter(e=>e.id!==n)))}var ro=()=>{let e=(0,Ii.c)(49),{t}=Me(),n=fe(io),r=Ce(),{project:i,list:a,scope:o}=to(n),s;e[0]===r?s=e[1]:(s={mutationFn:e=>{let{scope:t,id:n}=e;return no(r,t,n)}},e[0]=r,e[1]=s);let c=we(s),l;e[2]!==c.variables||e[3]!==o?(l=c.variables&&JSON.stringify(c.variables.scope)===JSON.stringify(o),e[2]=c.variables,e[3]=o,e[4]=l):l=e[4];let u=l,d=i.isError||a.isError,f=!!o.directory&&(i.isPending||a.isPending)&&!d,p;e[5]===a.data?p=e[6]:(p=a.data??[],e[5]=a.data,e[6]=p);let m=p,h;e[7]!==c||e[8]!==o?(h=e=>c.mutate({scope:o,id:e}),e[7]=c,e[8]=o,e[9]=h):h=e[9];let g=Ae(h),_;e[10]!==a||e[11]!==i?(_=()=>{i.isError?i.refetch():a.refetch()},e[10]=a,e[11]=i,e[12]=_):_=e[12];let v=Ae(_);if(!d&&!f&&m.length===0)return null;let y;e[13]===t?y=e[14]:(y=t(`settings.permissions.saved.title`),e[13]=t,e[14]=y);let b;e[15]!==f||e[16]!==t?(b=f?t(`common.loading`):void 0,e[15]=f,e[16]=t,e[17]=b):b=e[17];let x;e[18]!==d||e[19]!==a.isFetching||e[20]!==i.isFetching||e[21]!==v||e[22]!==t?(x=d&&(0,$.jsx)(Nr,{label:(0,$.jsx)(`span`,{role:`alert`,children:t(`settings.permissions.saved.loadFailed`)}),children:(0,$.jsx)(J,{type:`button`,variant:`ghost`,size:`xs`,onClick:v,disabled:i.isFetching||a.isFetching,children:t(`settings.permissions.saved.retry`)})}),e[18]=d,e[19]=a.isFetching,e[20]=i.isFetching,e[21]=v,e[22]=t,e[23]=x):x=e[23];let S;e[24]!==c.isError||e[25]!==u||e[26]!==t?(S=u&&c.isError&&(0,$.jsx)(Nr,{label:(0,$.jsx)(`span`,{role:`alert`,children:t(`settings.permissions.saved.deleteFailed`)}),children:null}),e[24]=c.isError,e[25]=u,e[26]=t,e[27]=S):S=e[27];let C;if(e[28]!==c.isPending||e[29]!==d||e[30]!==g||e[31]!==m||e[32]!==f||e[33]!==u||e[34]!==t){let n;e[36]!==c.isPending||e[37]!==d||e[38]!==g||e[39]!==f||e[40]!==u||e[41]!==t?(n=e=>(0,$.jsx)(Nr,{label:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{children:e.action}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground font-mono`,children:e.resource})]}),children:(0,$.jsx)(J,{type:`button`,variant:`ghost`,size:`xs`,disabled:d||f||!!(u&&c.isPending),onClick:()=>void g(e.id),children:t(`settings.permissions.saved.delete`)})},e.id),e[36]=c.isPending,e[37]=d,e[38]=g,e[39]=f,e[40]=u,e[41]=t,e[42]=n):n=e[42],C=m.map(n),e[28]=c.isPending,e[29]=d,e[30]=g,e[31]=m,e[32]=f,e[33]=u,e[34]=t,e[35]=C}else C=e[35];let w;return e[43]!==y||e[44]!==b||e[45]!==x||e[46]!==S||e[47]!==C?(w=(0,$.jsx)(`div`,{"data-settings-item":`permissions.saved`,className:`mb-6`,children:(0,$.jsxs)(vi,{label:y,description:b,children:[x,S,C]})}),e[43]=y,e[44]=b,e[45]=x,e[46]=S,e[47]=C,e[48]=w):w=e[48],w};function io(e){return e.currentDirectory}var ao=[`*`,`read`,`edit`,`glob`,`grep`,`shell`,`subagent`,`skill`,`webfetch`,`websearch`,`question`,`external_directory`,`execute`,`browser`],oo={"*":`settings.agents.page.permissions.defaultLabel`,shell:`settings.agents.page.permissions.shell`,bash:`settings.agents.page.permissions.shell`,subagent:`settings.agents.page.permissions.subagent`,task:`settings.agents.page.permissions.subagent`,edit:`settings.agents.page.permissions.edit`,write:`settings.agents.page.permissions.edit`,patch:`settings.agents.page.permissions.edit`,apply_patch:`settings.agents.page.permissions.edit`,multiedit:`settings.agents.page.permissions.edit`,external_directory:`settings.agents.page.permissions.externalDirectory`,question:`settings.agents.page.permissions.question`,read:`settings.agents.page.permissions.read`,glob:`settings.agents.page.permissions.glob`,grep:`settings.agents.page.permissions.grep`,skill:`settings.agents.page.permissions.skill`,webfetch:`settings.agents.page.permissions.webfetch`,websearch:`settings.agents.page.permissions.websearch`,execute:`settings.agents.page.permissions.execute`,browser:`settings.agents.page.permissions.browser`,session_rename:`chat.tools.display.session_rename`,session_move:`chat.tools.display.session_move`},so=e=>e===`allow`||e===`ask`||e===`deny`,co=(e,t)=>`${e}::${t}`,lo=e=>e===`bash`?`shell`:e===`task`?`subagent`:e===`write`||e===`patch`?`edit`:e,uo=e=>{let t=new Map;for(let n of e){let e=lo(n.permission);!e||e===`invalid`||n.pattern&&so(n.action)&&t.set(co(e,n.pattern),{permission:e,pattern:n.pattern,action:n.action})}return Array.from(t.values())},fo=e=>{let t=new Map;for(let n of uo(e))t.set(co(n.permission,n.pattern),n);return t},po=e=>[...e].sort((e,t)=>{let n=e.permission.localeCompare(t.permission);return n===0?e.pattern.localeCompare(t.pattern):n}),mo=(e,t)=>{let n=po(uo(e)),r=po(uo(t));return n.length===r.length&&n.every((e,t)=>{let n=r[t];return e.permission===n.permission&&e.pattern===n.pattern&&e.action===n.action})},ho=e=>e.find(e=>e.permission===`*`&&e.pattern===`*`)?.action??`allow`,go=(e,t)=>uo(e).filter(e=>e.permission!==`*`||e.pattern!==`*`).filter(e=>e.pattern!==`*`||e.action!==t),_o=e=>{if(Array.isArray(e))return uo(e.flatMap(e=>!e||typeof e!=`object`||typeof e.action!=`string`||typeof e.resource!=`string`||!so(e.effect)?[]:[{permission:e.action,pattern:e.resource,action:e.effect}]));if(so(e))return[{permission:`*`,pattern:`*`,action:e}];if(!e||typeof e!=`object`||Array.isArray(e))return[];let t=[];for(let[n,r]of Object.entries(e))if(n!==`__originalKeys`){if(so(r)){t.push({permission:n,pattern:`*`,action:r});continue}if(r&&typeof r==`object`&&!Array.isArray(r))for(let[e,i]of Object.entries(r))so(i)&&t.push({permission:n,pattern:e,action:i})}return t},vo=()=>{let{t:e}=Me(),{selectedAgentName:t,getAgentByName:n,createAgent:r,updateAgent:i,agentDraft:a,setAgentDraft:o}=Pt(le(e=>({selectedAgentName:e.selectedAgentName,getAgentByName:e.getAgentByName,createAgent:e.createAgent,updateAgent:e.updateAgent,agentDraft:e.agentDraft,setAgentDraft:e.setAgentDraft}))),{data:s=[]}=bt(),c=t?n(t):null,u=!!(a&&a.name===t&&!c),[d,f]=Q.useState(``),[p,m]=Q.useState(`user`),[h,g]=Q.useState(``),[_,v]=Q.useState(`subagent`),[y,b]=Q.useState(``),[x,S]=Q.useState(``),[C,w]=Q.useState(!1),[T,E]=Q.useState(`allow`),[D,O]=Q.useState([]),[k,A]=Q.useState([]),[j,M]=Q.useState(``),[N,P]=Q.useState(`*`),[F,I]=Q.useState(!1),[L,R]=Q.useState(!1),z=Q.useRef(null),B=fe(e=>e.currentDirectory??null),[V,H]=Q.useState([]),U=Tt(e=>e.permission);Q.useEffect(()=>{let e=!1;return(async()=>{let t=await pe.listToolIds({directory:B});if(e)return;let n=new Set([`write`,`patch`,`multiedit`]),r=t.map(e=>typeof e==`string`?e.trim():``).filter(Boolean).filter(e=>e!==`*`).filter(e=>e!==`invalid`).filter(e=>!n.has(e));H(Array.from(new Set(r)).sort((e,t)=>e.localeCompare(t)))})(),()=>{e=!0}},[B]);let W=Q.useMemo(()=>{let e=new Set;for(let t of s){let n=uo(_o(t.permissions??t.permission));for(let t of n)t.permission&&t.permission!==`*`&&t.permission!==`invalid`&&e.add(t.permission)}for(let t of Object.values(U))for(let n of t){let t=n.permission?.trim();t&&t!==`invalid`&&e.add(t)}for(let t of V)e.add(t);return Array.from(e).sort((e,t)=>e.localeCompare(t))},[s,U,V]),ee=Q.useMemo(()=>fo(D),[D]),G=Q.useMemo(()=>fo(k),[k]),te=e=>G.get(co(e,`*`))?.action,ne=e=>k.filter(t=>t.permission===e&&t.pattern!==`*`).sort((e,t)=>e.pattern.localeCompare(t.pattern)),re=Q.useMemo(()=>{let e=new Set;for(let t of ao)e.add(t);for(let t of W)e.add(t);return Array.from(e).sort((e,t)=>e.localeCompare(t))},[W]),ie=e=>{let t=e===`*`?T:te(e)??T,n=ne(e),r=n.reduce((e,t)=>(e[t.action]=(e[t.action]??0)+1,e),{allow:0,ask:0,deny:0}),i=[`allow`,`ask`,`deny`].filter(e=>r[e]>0).map(e=>`${r[e]} ${e}`).join(`, `);return{defaultAction:t,patternRulesCount:n.length,patternSummary:i,hasDefaultHint:!1}},ae=t=>e(t===`allow`?`settings.common.permission.allow`:t===`deny`?`settings.common.permission.deny`:`settings.common.permission.ask`),oe=t=>t===`global`?e(`settings.common.scope.global`):ae(t),se=Q.useMemo(()=>{let e=new Set;for(let t of ao)e.add(t);for(let t of W)e.add(t);return Array.from(e).sort((e,t)=>e.localeCompare(t))},[W]),ce=(e,t,n)=>{A(r=>{let i=fo(r);return i.set(co(e,t),{permission:e,pattern:t,action:n}),Array.from(i.values())})},ue=(e,t)=>{A(n=>{let r=fo(n);return r.delete(co(e,t)),Array.from(r.values())})},de=(e,t)=>{let n=ee.get(co(e,t));if(n){ce(e,t,n.action);return}ue(e,t)},me=(e,t,n)=>{ce(e,t,n)},he=e=>{E(e),A(t=>t.filter(t=>t.pattern!==`*`||t.action!==e))},ge=t=>{let n=j.trim();if(!n){Y.error(e(`settings.agents.page.toast.permissionNameRequired`));return}let r=N.trim()||`*`;if(n===`*`&&r===`*`){he(t),M(``),P(`*`);return}r===`*`&&n!==`*`&&t===T?ue(n,`*`):ce(n,r,t),M(``),P(`*`)},_e=t=>{let n=oo[t];return n?e(n):t.split(/[_-]+/g).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)};Q.useEffect(()=>{M(``),P(`*`);let e=e=>{let t=uo(e),n=ho(t),r=go(t,n);return E(n),O(r),A(r),{global:n,rules:r}};if(u&&a){let t=a.name||``,n=a.scope||`user`,r=a.description||``,i=a.mode||`subagent`,o=a.model||``,s=a.system||``;f(t),m(n),g(r),v(i),b(o),S(s),w(!1);let c=e(_o(a.permissions));z.current={draftName:t,draftScope:n,description:r,mode:i,model:o,system:s,globalPermission:c.global,permissionRules:c.rules};return}if(c&&t===c.name){let t=c,n=c.description||``,r=c.mode||`subagent`,i=Da(c),a=t.scope===`project`?`project`:`user`;m(a),g(n),v(r),b(i),S(``),w(!1);let o=e(_o(t.permissions??c.permission));z.current={draftName:``,draftScope:a,description:n,mode:r,model:i,system:``,globalPermission:o.global,permissionRules:o.rules}}},[a,u,c,t]),Q.useEffect(()=>{if(!t||u)return;let e=new AbortController,n=zt();return l(`/api/config/agents/${encodeURIComponent(t)}/config`,{signal:e.signal,headers:n?{"x-opencode-directory":n}:{}}).then(async t=>{if(!t.ok||e.signal.aborted)return;let n=Ea((await t.json()).config);e.signal.aborted||n===void 0||!z.current||(S(n),z.current={...z.current,system:n})}).catch(()=>void 0),()=>e.abort()},[u,t]);let ve=Q.useMemo(()=>{let e=z.current;return e?!!(u&&d!==e.draftName||p!==e.draftScope||h!==e.description||_!==e.mode||y!==e.model||x!==e.system||T!==e.globalPermission||!mo(k,e.permissionRules)):!1},[h,d,p,T,u,_,y,k,x]),K=(!u&&c?c.document:void 0)?.dropped?.map(e=>e.key)??[],ye=!L&&ve;return t?(0,$.jsx)(Sr,{outerClassName:`h-full`,className:`w-full`,children:(0,$.jsxs)(`div`,{className:`oc-settings-page-content mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8`,children:[(0,$.jsx)(ro,{}),(0,$.jsxs)(`div`,{className:`mb-4 flex items-center justify-between gap-4`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`h2`,{className:`typography-ui-header font-semibold text-foreground truncate`,children:u?e(`settings.agents.page.title.new`):Aa(t??``)}),(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground truncate`,children:e(u?`settings.agents.page.subtitle.new`:`settings.agents.page.subtitle.edit`)})]}),(0,$.jsx)(J,{type:`button`,onClick:async()=>{let n=u?d.trim().replace(/\s+/g,`-`):t?.trim();if(!n){Y.error(e(`settings.agents.sidebar.toast.agentNameRequired`));return}if(u&&s.some(e=>e.name===n)){Y.error(e(`settings.agents.sidebar.toast.agentExists`));return}R(!0);try{let t={description:h,mode:_,model:y,system:x,globalPermission:T,permissionRules:k},s=z.current,c=s?{description:s.description,mode:s.mode,model:s.model,system:s.system,globalPermission:s.globalPermission,permissionRules:s.permissionRules}:null,l=Ta({isNewAgent:u,agentName:n,draftScope:p,initialScope:s?.draftScope,draftHasExplicitPermission:u&&a?.permissions!==void 0,current:t,initial:c,confirmDrop:C}),d;u?(d=await r(l),d.ok&&o(null)):d=await i(n,l),d.ok?d.requiresManualRestart?Y.warning(e(`settings.agents.page.toast.savedManualRestart`)):Y.success(e(`settings.agents.page.toast.savedNextRequest`)):Y.error(e(u?`settings.agents.page.toast.createFailed`:`settings.agents.page.toast.updateFailed`))}catch(t){console.error(`Error saving agent:`,t);let n=t instanceof Error&&t.message?t.message:e(`settings.agents.page.toast.saveUnexpectedError`);Y.error(n)}finally{R(!1)}},disabled:!ye,children:e(L?`settings.common.actions.saving`:`settings.common.actions.saveChanges`)})]}),K.length>0?(0,$.jsxs)(`div`,{className:`mt-3 flex flex-col gap-2`,children:[(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:e(`settings.agents.page.legacy.dropped`,{fields:K.join(`, `)})}),(0,$.jsxs)(`label`,{className:`flex items-center gap-2 typography-meta text-foreground`,children:[(0,$.jsx)(sn,{checked:C,onChange:w,ariaLabel:e(`settings.agents.page.legacy.confirmDrop`)}),e(`settings.agents.page.legacy.confirmDrop`)]})]}):null,(0,$.jsxs)(vi,{label:e(`settings.agents.page.section.identityRole`),children:[(0,$.jsx)(Nr,{itemId:`agents.scope`,label:e(`settings.agents.page.field.scope`),children:(0,$.jsxs)(ln,{value:p,onValueChange:e=>m(e),children:[(0,$.jsx)(rn,{className:`w-fit min-w-[100px]`,children:(0,$.jsx)(dn,{placeholder:e(`settings.agents.page.field.scopePlaceholder`),children:t=>(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(X,{name:t===`project`?`folder`:`user-3`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:e(t===`project`?`settings.common.scope.project`:`settings.common.scope.global`)})]})})}),(0,$.jsxs)(an,{align:`end`,children:[(0,$.jsx)(tn,{value:`user`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(X,{name:`user-3`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:e(`settings.common.scope.global`)})]})}),(0,$.jsx)(tn,{value:`project`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(X,{name:`folder`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:e(`settings.common.scope.project`)})]})})]})]})}),u&&(0,$.jsx)(Nr,{itemId:`agents.name`,label:e(`settings.agents.page.field.agentName`),children:(0,$.jsxs)(`div`,{className:`flex items-center`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-muted-foreground mr-1`,children:`@`}),(0,$.jsx)(fn,{value:d,onChange:e=>f(e.target.value),placeholder:e(`settings.agents.page.field.agentNamePlaceholder`),className:`h-7 w-40 px-2`})]})}),(0,$.jsx)(Nr,{label:e(`settings.common.field.description`),className:`oc-settings-split-row-stacked`,children:(0,$.jsx)(Cr,{embedded:!0,value:h,onChange:e=>g(e.target.value),placeholder:e(`settings.agents.page.field.descriptionPlaceholder`),rows:2,className:`w-full resize-none min-h-[60px] bg-transparent`})}),(0,$.jsx)(Nr,{itemId:`agents.mode`,className:`oc-settings-agents-mode-row`,label:(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{children:e(`settings.agents.page.field.mode`)}),(0,$.jsxs)(hn,{children:[(0,$.jsx)(pn,{asChild:!0,children:(0,$.jsx)(X,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(mn,{sideOffset:8,className:`max-w-xs`,children:e(`settings.agents.page.field.modeTooltip`)})]})]}),children:(0,$.jsxs)(`div`,{className:`flex flex-nowrap items-center justify-end gap-1`,children:[(0,$.jsx)(J,{variant:`chip`,size:`xs`,"aria-pressed":_===`primary`,onClick:()=>v(`primary`),className:`!font-normal shrink-0`,children:e(`settings.agents.page.mode.primary`)}),(0,$.jsx)(J,{variant:`chip`,size:`xs`,"aria-pressed":_===`subagent`,onClick:()=>v(`subagent`),className:`!font-normal shrink-0`,children:e(`settings.agents.page.mode.subagent`)}),(0,$.jsx)(J,{variant:`chip`,size:`xs`,"aria-pressed":_===`all`,onClick:()=>v(`all`),className:`!font-normal shrink-0`,children:e(`settings.agents.page.mode.all`)})]})})]}),(0,$.jsx)(vi,{label:e(`settings.agents.page.section.modelParameters`),children:(0,$.jsx)(Nr,{itemId:`agents.model`,label:e(`settings.agents.page.field.overrideModel`),children:(0,$.jsx)(Tn,{providerId:Oa(y)?.providerId??``,modelId:Oa(y)?.modelId??``,variant:Oa(y)?.variant??``,onChange:(e,t,n)=>{b(e&&t?n?`${e}/${t}#${n}`:`${e}/${t}`:``)},className:`oc-settings-inline-value`})})}),(0,$.jsx)(Jr,{itemId:`agents.system-prompt`,label:e(`settings.agents.page.section.systemPrompt`),className:`oc-settings-split-row-stacked`,children:(0,$.jsx)(Cr,{embedded:!0,value:x,onChange:e=>S(e.target.value),placeholder:e(`settings.agents.page.field.systemPromptPlaceholder`),rows:8,className:`w-full font-mono typography-meta min-h-[120px] max-h-[60vh] bg-transparent resize-y`})}),(0,$.jsx)(`div`,{"data-settings-item":`agents.permissions`,children:(0,$.jsx)(vi,{label:(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,$.jsx)(`span`,{children:e(`settings.agents.page.section.toolPermissions`)}),(0,$.jsx)(J,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>I(e=>!e),children:e(F?`settings.agents.page.permissions.hideEditor`:`settings.agents.page.permissions.advancedEditor`)})]}),children:F?(0,$.jsxs)(`div`,{className:`space-y-6 p-2`,children:[(0,$.jsx)(Nr,{label:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{children:e(`settings.agents.page.permissions.globalDefault`)}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground/70 font-mono`,children:`*`})]}),children:(0,$.jsxs)(ln,{value:T,onValueChange:e=>he(e),children:[(0,$.jsx)(rn,{className:`w-[100px]`,children:(0,$.jsx)(dn,{children:ae(T)})}),(0,$.jsxs)(an,{children:[(0,$.jsx)(tn,{value:`allow`,children:e(`settings.common.permission.allow`)}),(0,$.jsx)(tn,{value:`ask`,children:e(`settings.common.permission.ask`)}),(0,$.jsx)(tn,{value:`deny`,children:e(`settings.common.permission.deny`)})]})]})}),(0,$.jsx)(`div`,{className:`space-y-4`,children:re.filter(e=>e!==`*`).map(t=>{let n=_e(t),{defaultAction:r,patternRulesCount:i}=ie(t),a=te(t),o=a??`global`,s=ne(t),c=[`allow`,`ask`,`deny`].filter(e=>e!==T);return(0,$.jsxs)(`div`,{className:`border-t border-[var(--surface-subtle)] pt-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between py-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:n}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground/70 font-mono`,children:t})]}),(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground`,children:i>0?e(`settings.agents.page.permissions.globalSummary`,{summary:r}):r})]}),(0,$.jsxs)(`div`,{className:`space-y-1 pl-2 mt-1`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 py-0.5`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:e(`settings.agents.page.permissions.pattern`)}),(0,$.jsx)(`span`,{className:`typography-micro font-mono text-foreground bg-[var(--surface-muted)] px-1 rounded`,children:`*`}),a&&(0,$.jsx)(J,{size:`sm`,variant:`ghost`,onClick:()=>de(t,`*`),className:`px-1.5 py-0 h-5`,children:(0,$.jsx)(X,{name:`subtract`,className:`h-3.5 w-3.5 text-muted-foreground hover:text-foreground`})})]}),(0,$.jsxs)(ln,{value:o,onValueChange:e=>{if(e===`global`){ue(t,`*`);return}ce(t,`*`,e)},children:[(0,$.jsx)(rn,{className:`w-[90px]`,children:(0,$.jsx)(dn,{children:oe(o)})}),(0,$.jsxs)(an,{children:[(0,$.jsx)(tn,{value:`global`,children:e(`settings.common.scope.global`)}),c.map(e=>(0,$.jsx)(tn,{value:e,className:`capitalize`,children:ae(e)},e))]})]})]}),s.map(t=>{let n=co(t.permission,t.pattern),r=ee.get(n),i=!r,a=!!(r&&r.action!==t.action);return(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 py-0.5 border-t border-[var(--surface-subtle)]`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:e(`settings.agents.page.permissions.pattern`)}),(0,$.jsx)(`span`,{className:`typography-micro font-mono text-foreground bg-[var(--surface-muted)] px-1 rounded`,children:t.pattern}),i&&(0,$.jsx)(`span`,{className:`typography-micro text-[var(--status-success)]`,children:e(`settings.common.badge.new`)}),a&&(0,$.jsx)(`span`,{className:`typography-micro text-[var(--status-warning)]`,children:e(`settings.common.badge.modified`)}),(i||a)&&(0,$.jsx)(J,{size:`sm`,variant:`ghost`,onClick:()=>i?ue(t.permission,t.pattern):de(t.permission,t.pattern),className:`px-1.5 py-0 h-5`,children:(0,$.jsx)(X,{name:`subtract`,className:`h-3.5 w-3.5 text-muted-foreground hover:text-foreground`})})]}),(0,$.jsxs)(ln,{value:t.action,onValueChange:e=>me(t.permission,t.pattern,e),children:[(0,$.jsx)(rn,{className:`w-[90px]`,children:(0,$.jsx)(dn,{children:ae(t.action)})}),(0,$.jsxs)(an,{children:[(0,$.jsx)(tn,{value:`allow`,children:e(`settings.common.permission.allow`)}),(0,$.jsx)(tn,{value:`ask`,children:e(`settings.common.permission.ask`)}),(0,$.jsx)(tn,{value:`deny`,children:e(`settings.common.permission.deny`)})]})]})]},n)})]})]},t)})}),(0,$.jsxs)(`div`,{className:`border-t border-[var(--surface-subtle)] pt-3`,children:[(0,$.jsx)(`h4`,{className:`typography-ui-label text-foreground mb-2`,children:e(`settings.agents.page.permissions.addCustomRule`)}),(0,$.jsxs)(`div`,{className:`flex flex-col sm:flex-row items-end sm:items-center gap-2`,children:[(0,$.jsxs)(ln,{value:j,onValueChange:M,children:[(0,$.jsx)(rn,{className:`w-full sm:w-[160px]`,children:j?(0,$.jsx)(`span`,{className:`truncate`,children:_e(j)}):(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:e(`settings.agents.page.permissions.permissionPlaceholder`)})}),(0,$.jsx)(an,{children:se.map(e=>(0,$.jsx)(tn,{value:e,children:(0,$.jsx)(`div`,{className:`flex items-center justify-between gap-2 w-full`,children:(0,$.jsx)(`span`,{children:_e(e)})})},e))})]}),(0,$.jsx)(fn,{value:N,onChange:e=>P(e.target.value),placeholder:e(`settings.agents.page.permissions.patternPlaceholder`),className:`h-7 flex-1 font-mono text-xs`}),(0,$.jsxs)(`div`,{className:`flex gap-1`,children:[(0,$.jsx)(J,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>ge(`allow`),children:e(`settings.common.permission.allow`)}),(0,$.jsx)(J,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>ge(`ask`),children:e(`settings.common.permission.ask`)}),(0,$.jsx)(J,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>ge(`deny`),children:e(`settings.common.permission.deny`)})]})]})]})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground px-3 pt-2`,children:e(`settings.agents.page.permissions.lastMatchHint`)}),Fn(gr(k)).map((e,t)=>(0,$.jsx)(Nr,{label:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground font-mono`,children:t+1}),(0,$.jsx)(`span`,{children:e.action}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground/70 font-mono`,children:e.resource})]}),children:(0,$.jsx)(`span`,{className:q(`typography-micro capitalize px-1.5 py-0.5 rounded`,e.effect===`allow`?`text-[var(--status-success)] bg-[var(--status-success)]/10`:e.effect===`deny`?`text-[var(--status-error)] bg-[var(--status-error)]/10`:`text-[var(--status-warning)] bg-[var(--status-warning)]/10`),children:e.effect})},`${e.action}::${e.resource}::${t}`))]})})})]})}):(0,$.jsx)(Sr,{outerClassName:`h-full`,className:`w-full`,children:(0,$.jsxs)(`div`,{className:`oc-settings-page-content mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8`,children:[(0,$.jsx)(ro,{}),(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,$.jsxs)(`div`,{className:`text-center text-muted-foreground`,children:[(0,$.jsx)(X,{name:`robot-2`,className:`mx-auto mb-3 h-12 w-12 opacity-50`}),(0,$.jsx)(`p`,{className:`typography-body`,children:e(`settings.agents.page.empty.title`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 opacity-75`,children:e(`settings.agents.page.empty.description`)})]})})]})})},yo=e=>{let t=(0,Ii.c)(23),{title:n,metadata:r,selected:i,onSelect:a,icon:o,actions:s,className:c}=e,l=i!==void 0&&i,u=s&&s.length>0,d=l?`bg-interactive-selection`:`hover:bg-interactive-hover`,f;t[0]!==c||t[1]!==d?(f=q(`oc-settings-group-row group relative flex items-center transition-colors duration-150`,d,c),t[0]=c,t[1]=d,t[2]=f):f=t[2];let p;t[3]===n?p=t[4]:(p=(0,$.jsx)(`span`,{className:`typography-ui-label font-normal truncate text-foreground`,children:n}),t[3]=n,t[4]=p);let m;t[5]!==o||t[6]!==p?(m=(0,$.jsxs)(`div`,{className:`flex max-w-full min-w-0 items-center gap-1.5`,children:[o,p]}),t[5]=o,t[6]=p,t[7]=m):m=t[7];let h;t[8]===r?h=t[9]:(h=r&&(0,$.jsx)(`div`,{className:`max-w-full truncate typography-micro leading-tight text-muted-foreground/60`,children:r}),t[8]=r,t[9]=h);let g;t[10]!==a||t[11]!==m||t[12]!==h?(g=(0,$.jsxs)(`button`,{onClick:a,"data-mobile-press-feedback":`soft`,className:`flex min-w-0 flex-1 self-stretch flex-col justify-center gap-0 rounded-sm text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,tabIndex:0,children:[m,h]}),t[10]=a,t[11]=m,t[12]=h,t[13]=g):g=t[13];let _;t[14]!==s||t[15]!==u?(_=u&&(0,$.jsxs)(cr,{children:[(0,$.jsx)(mr,{asChild:!0,children:(0,$.jsx)(J,{size:`icon`,variant:`ghost`,className:`h-6 w-6 flex-shrink-0 -mr-1 opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100`,children:(0,$.jsx)(X,{name:`more-2`,className:`h-3.5 w-3.5`})})}),(0,$.jsx)(Qn,{align:`end`,className:`w-fit min-w-20`,children:s.map(bo)})]}),t[14]=s,t[15]=u,t[16]=_):_=t[16];let v;t[17]!==g||t[18]!==_?(v=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 self-stretch items-center`,children:[g,_]}),t[17]=g,t[18]=_,t[19]=v):v=t[19];let y;return t[20]!==f||t[21]!==v?(y=(0,$.jsx)(`div`,{className:f,children:v}),t[20]=f,t[21]=v,t[22]=y):y=t[22],y};function bo(e){let t=e.icon;return(0,$.jsxs)(Wn,{onClick:t=>{t.stopPropagation(),e.onClick()},className:q(e.destructive&&`text-destructive focus:text-destructive`),children:[t&&(0,$.jsx)(X,{name:t,className:`h-4 w-4 mr-px`}),e.label]},e.label)}var xo=e=>{let t=(0,Ii.c)(8),{header:n,footer:r,children:i,className:a,variant:o}=e,s=o===void 0?`sidebar`:o,c=k(),l=s===`background`||c?`bg-background`:`bg-sidebar`,u;t[0]!==l||t[1]!==a?(u=q(`oc-settings-page-content h-full overflow-y-auto p-3`,l,a),t[0]=l,t[1]=a,t[2]=u):u=t[2];let d;return t[3]!==i||t[4]!==r||t[5]!==n||t[6]!==u?(d=(0,$.jsxs)(`div`,{className:u,children:[n,i,r]}),t[3]=i,t[4]=r,t[5]=n,t[6]=u,t[7]=d):d=t[7],d},So=`__managed_workspace__`,Co=`__current_workspace__`,wo=`默认助理`,To=()=>{let e=Mt.getState(),t=e.settingsDefaultModel;if(t){let e=Ht(t);if(e?.providerId&&e?.modelId)return{providerID:e.providerId,modelID:e.modelId}}if(e.currentProviderId&&e.currentModelId)return{providerID:e.currentProviderId,modelID:e.currentModelId};let n=e.providers;for(let e of n){let t=e.models;if(Array.isArray(t)&&t.length>0){let n=t[0];if(n?.id)return{providerID:e.id,modelID:n.id}}}return null},Eo=(e=``)=>{let t=To();return{enabled:!0,name:e,defaultPrompt:``,workspacePath:null,providerID:t?.providerID??``,modelID:t?.modelID??``,variant:null}},Do=e=>({enabled:e.enabled,name:e.name,defaultPrompt:e.defaultPrompt,workspacePath:e.workspacePath,providerID:e.providerID,modelID:e.modelID,variant:e.variant}),Oo=e=>({enabled:e.enabled,name:e.name,defaultPrompt:e.defaultPrompt,workspacePath:e.workspacePath,providerID:e.providerID,modelID:e.modelID,variant:e.variant??null}),ko=e=>e.label?.trim()||e.path.replace(/[\\/]+$/,``).split(/[\\/]/).filter(Boolean).at(-1)||e.path,Ao=e=>{let t=Array.isArray(e.schedule.times)?e.schedule.times:e.schedule.time?[e.schedule.time]:[];return Array.from(new Set(t.filter(e=>/^([01]\d|2[0-3]):([0-5]\d)$/.test(e)))).sort((e,t)=>e.localeCompare(t))},jo=e=>!!e&&typeof e==`object`&&!Array.isArray(e),Mo=e=>{if(!jo(e)||!jo(e.schedule)||!jo(e.execution)||!jo(e.state))return!1;let t=e.schedule.times===void 0||Array.isArray(e.schedule.times)&&e.schedule.times.every(e=>typeof e==`string`),n=e.schedule.weekdays===void 0||Array.isArray(e.schedule.weekdays)&&e.schedule.weekdays.every(e=>typeof e==`number`),r=e.state.lastStatus===void 0||e.state.lastStatus===`idle`||e.state.lastStatus===`running`||e.state.lastStatus===`success`||e.state.lastStatus===`error`;return typeof e.id==`string`&&typeof e.name==`string`&&typeof e.enabled==`boolean`&&(e.schedule.kind===`daily`||e.schedule.kind===`weekly`||e.schedule.kind===`once`||e.schedule.kind===`cron`)&&t&&n&&r&&typeof e.execution.prompt==`string`&&typeof e.execution.providerID==`string`&&typeof e.execution.modelID==`string`},No=(e,t)=>{let n=Ao(e).join(`, `)||`—`,r=e=>t(e===0?`sessions.scheduledTasks.dialog.schedule.weekdayShort.sun`:e===1?`sessions.scheduledTasks.dialog.schedule.weekdayShort.mon`:e===2?`sessions.scheduledTasks.dialog.schedule.weekdayShort.tue`:e===3?`sessions.scheduledTasks.dialog.schedule.weekdayShort.wed`:e===4?`sessions.scheduledTasks.dialog.schedule.weekdayShort.thu`:e===5?`sessions.scheduledTasks.dialog.schedule.weekdayShort.fri`:e===6?`sessions.scheduledTasks.dialog.schedule.weekdayShort.sat`:`sessions.scheduledTasks.dialog.schedule.weekdayShort.unknown`);if(e.schedule.kind===`daily`)return e.schedule.timezone?t(`sessions.scheduledTasks.dialog.schedule.dailyWithTimezone`,{time:n,timezone:e.schedule.timezone}):t(`sessions.scheduledTasks.dialog.schedule.daily`,{time:n});if(e.schedule.kind===`weekly`){let i=(e.schedule.weekdays??[]).map(r).join(`, `);return e.schedule.timezone?t(`sessions.scheduledTasks.dialog.schedule.weeklyWithTimezone`,{days:i,time:n,timezone:e.schedule.timezone}):t(`sessions.scheduledTasks.dialog.schedule.weekly`,{days:i,time:n})}if(e.schedule.kind===`once`){let n=e.schedule.date?.trim()||t(`sessions.scheduledTasks.dialog.schedule.unknownDate`),r=e.schedule.time?.trim()||`—`;return e.schedule.timezone?t(`sessions.scheduledTasks.dialog.schedule.onceWithTimezone`,{date:n,time:r,timezone:e.schedule.timezone}):t(`sessions.scheduledTasks.dialog.schedule.once`,{date:n,time:r})}return e.schedule.timezone?t(`sessions.scheduledTasks.dialog.schedule.cronWithTimezone`,{cron:e.schedule.cron??``,timezone:e.schedule.timezone}):t(`sessions.scheduledTasks.dialog.schedule.cron`,{cron:e.schedule.cron??``})},Po={paused:{icon:`pause`,className:`text-muted-foreground`},idle:{icon:`pulse`,className:`text-muted-foreground`},running:{icon:`loader-4`,className:`text-[var(--status-warning)]`},success:{icon:`checkbox-circle`,className:`text-[var(--status-success)]`},error:{icon:`error-warning`,className:`text-[var(--status-error)]`}},Fo=e=>`${e.projectId}:${e.task.id}`,Io=e=>{let t=(0,Ii.c)(31),{assistantID:n}=e,{t:r}=Me(),i=qe(n),a=i.isError,o=Re(n,a),s=Je(a),c=new Set;for(let e of o.data?.messages??[])for(let t of e.cards)t.cardType===`schedule`&&c.add(`${t.projectID}:${t.taskID}`);let l=(i.data?.tasks??[]).flatMap(Bo),u;t[0]===i.data?.tasks?u=t[1]:(u=i.data?.tasks.some(Vo),t[0]=i.data?.tasks,t[1]=u);let d=!!u,f=(s.data?.tasks??[]).filter(e=>c.has(Fo(e))),p=[...i.data?l:a?f:[]].sort(Ho),m=(s.data?.failedProjectIds??[]).some(e=>Array.from(c).some(t=>t.startsWith(`${e}:`))),h=i.isPending||a&&(o.isPending||s.isPending),g=i.isError||o.isError||s.isError||m||d,_=Ae(Uo),v;t[2]!==o||t[3]!==a||t[4]!==s||t[5]!==i?(v=()=>{i.refetch(),a&&(o.refetch(),s.refetch())},t[2]=o,t[3]=a,t[4]=s,t[5]=i,t[6]=v):v=t[6];let y=Ae(v),b=vi,x;t[7]===r?x=t[8]:(x=r(`assistants.settings.scheduledTasks.title`),t[7]=r,t[8]=x);let S;t[9]===r?S=t[10]:(S=r(`assistants.settings.scheduledTasks.title`),t[9]=r,t[10]=S);let C=h&&p.length===0?(0,$.jsx)(Nr,{label:r(`common.loading`),children:(0,$.jsx)(X,{name:`loader-4`,className:`size-4 animate-spin text-muted-foreground`})}):null,w;t[11]!==_||t[12]!==r?(w=e=>{let t=e.task.enabled?e.task.state?.lastStatus??`idle`:`paused`,n=Po[t],i=r(t===`paused`?`sessions.scheduledTasks.dialog.taskToggle.paused`:t===`running`?`sessions.scheduledTasks.dialog.status.running`:t===`success`?`sessions.scheduledTasks.dialog.status.success`:t===`error`?`sessions.scheduledTasks.dialog.status.error`:`sessions.scheduledTasks.dialog.status.idle`);return(0,$.jsxs)(Nr,{className:`group relative cursor-pointer transition-colors hover:bg-interactive-hover`,label:(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-3`,children:[(0,$.jsx)(`span`,{className:`flex size-7 shrink-0 items-center justify-center rounded-lg bg-[var(--surface-muted)] text-muted-foreground`,children:(0,$.jsx)(X,{name:`calendar`,className:`size-3.5`})}),(0,$.jsxs)(`span`,{className:`min-w-0`,children:[(0,$.jsx)(`span`,{className:`block truncate typography-ui-label font-medium text-foreground`,children:e.task.name}),(0,$.jsx)(`span`,{className:`mt-0.5 block typography-micro truncate text-muted-foreground`,children:No(e.task,r)})]})]}),controlClassName:`min-w-fit`,children:[(0,$.jsxs)(`span`,{className:`flex items-center gap-2 text-muted-foreground`,children:[(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 typography-micro ${n.className}`,children:[(0,$.jsx)(X,{name:n.icon,className:`size-3.5 ${t===`running`?`animate-spin`:``}`}),i]}),(0,$.jsx)(X,{name:`arrow-right-s`,className:`size-4`})]}),(0,$.jsx)(J,{type:`button`,variant:`ghost`,size:`icon`,className:`absolute inset-0 z-10 h-auto w-auto rounded-none bg-transparent p-0 hover:bg-transparent focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--interactive-focus-ring)]`,onClick:_,"aria-label":r(`assistants.settings.scheduledTasks.open`,{name:e.task.name}),children:(0,$.jsx)(`span`,{className:`sr-only`,children:r(`assistants.settings.scheduledTasks.open`,{name:e.task.name})})})]},Fo(e))},t[11]=_,t[12]=r,t[13]=w):w=t[13];let T=p.map(w),E;t[14]!==g||t[15]!==y||t[16]!==r?(E=g?(0,$.jsx)(Nr,{label:r(`assistants.settings.scheduledTasks.loadError`),children:(0,$.jsx)(J,{variant:`outline`,size:`sm`,onClick:y,children:r(`assistants.actions.retry`)})}):null,t[14]=g,t[15]=y,t[16]=r,t[17]=E):E=t[17];let D;t[18]!==g||t[19]!==h||t[20]!==r||t[21]!==p?(D=!h&&!g&&p.length===0?(0,$.jsx)(Nr,{label:r(`assistants.settings.scheduledTasks.empty`),children:(0,$.jsx)(X,{name:`calendar`,className:`size-4 text-muted-foreground`})}):null,t[18]=g,t[19]=h,t[20]=r,t[21]=p,t[22]=D):D=t[22];let O;return t[23]!==b||t[24]!==x||t[25]!==S||t[26]!==C||t[27]!==T||t[28]!==E||t[29]!==D?(O=(0,$.jsxs)(b,{label:x,ariaLabel:S,children:[C,T,E,D]}),t[23]=b,t[24]=x,t[25]=S,t[26]=C,t[27]=T,t[28]=E,t[29]=D,t[30]=O):O=t[30],O},Lo=e=>{let t=(0,Ii.c)(11),{name:n,path:r,icon:i}=e,a=i===void 0?`folder`:i,o;t[0]===a?o=t[1]:(o=(0,$.jsx)(X,{name:a,className:`size-4 shrink-0 text-muted-foreground`}),t[0]=a,t[1]=o);let s=r?`max-w-[40%] shrink-0 truncate typography-ui-label text-foreground`:`min-w-0 truncate typography-ui-label text-foreground`,c;t[2]!==n||t[3]!==s?(c=(0,$.jsx)(`span`,{className:s,children:n}),t[2]=n,t[3]=s,t[4]=c):c=t[4];let l;t[5]===r?l=t[6]:(l=r?(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate typography-micro text-muted-foreground`,title:r,children:r}):null,t[5]=r,t[6]=l);let u;return t[7]!==o||t[8]!==c||t[9]!==l?(u=(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[o,c,l]}),t[7]=o,t[8]=c,t[9]=l,t[10]=u):u=t[10],u},Ro=({onItemSelect:e})=>{let{t}=Me(),n=Ye(),r=Ve(),i=n.data,a=Kt(e=>e.settingsSelectedAssistantID),o=Kt(e=>e.selectSettingsAssistant),s=Kt(e=>e.requestCreate),[c,l]=Q.useState(!1);Q.useEffect(()=>{!e&&a===null&&i?.assistants[0]&&o(i.assistants[0].id)},[e,o,a,i?.assistants]),Q.useEffect(()=>{n.isSuccess&&a&&a!==`new`&&!i?.assistants.some(e=>e.id===a)&&o(e?null:i?.assistants[0]?.id??null)},[e,o,a,i?.assistants,n.isSuccess]);let u=Ae(()=>{s(),e?.()}),d=Ae(async e=>{if(i)try{if(await We(e,i.revision),e&&i.assistants.length===0){let e=To();if(e){let t=await Ue({enabled:!0,name:wo,defaultPrompt:``,workspacePath:null,providerID:e.providerID,modelID:e.modelID});o(t.id)}}}catch{Oe.error(t(`assistants.settings.toast.toggleFailed`))}});return r.isSuccess&&!r.data.supported?null:(0,$.jsx)(xo,{variant:`background`,header:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(vi,{description:(0,$.jsxs)($.Fragment,{children:[t(`assistants.settings.description`),(0,$.jsx)(`a`,{href:`#assistant-share-welcome`,className:`underline underline-offset-2`,onClick:e=>{e.preventDefault(),l(!0)},children:t(`assistants.settings.descriptionLearnMore`)})]}),children:(0,$.jsx)(Qr,{itemId:`assistants.instance-enabled`,checked:i?.enabled??!1,onChange:d,label:t(`assistants.settings.instanceEnabled`),ariaLabel:t(`assistants.settings.instanceEnabled`)})}),(0,$.jsx)(Qi,{open:c,onOpenChange:l})]}),children:(0,$.jsx)(vi,{label:(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:t(`assistants.settings.listTitle`)}),(0,$.jsx)(J,{"data-settings-item":`assistants.create`,variant:`ghost`,size:`icon`,onClick:u,"aria-label":t(`assistants.settings.create`),children:(0,$.jsx)(X,{name:`add`,className:`size-4`})})]}),children:n.isPending||r.isPending?(0,$.jsxs)(`div`,{className:`oc-settings-group-row flex items-center justify-center text-muted-foreground`,children:[(0,$.jsx)(X,{name:`loader-4`,className:`mr-2 size-4 animate-spin`}),t(`common.loading`)]}):i?.assistants.length?i.assistants.map(t=>{let n=Fe(t.name);return(0,$.jsx)(yo,{title:n.displayName,selected:a===t.id,onSelect:()=>{o(t.id),e?.()},icon:(0,$.jsx)($t,{name:t.id,emoji:n.avatarEmoji,size:24,label:n.displayName||t.name,shape:`circle`})},t.id)}):(0,$.jsx)(`div`,{className:`oc-settings-group-row text-muted-foreground`,children:t(`assistants.settings.empty`)})})})},zo=({onItemDeleted:e,assistantID:t})=>{let{t:n}=Me(),r=Ye(),i=Ve(),a=r.data,o=Ct(e=>e.projects),s=Kt(e=>t??e.settingsSelectedAssistantID),c=Kt(e=>e.selectSettingsAssistant),l=Kt(e=>e.defaultShareAssistant),u=Kt(e=>e.setDefaultShareAssistant),d=Kt(e=>e.createRequestRevision),f=Kt(e=>e.requestCreate),[p,m]=Q.useState(Eo),[h,g]=Q.useState(!1),_=Q.useRef(0),v=a?.assistants.find(e=>e.id===s)??null,y=v?Fe(v.name):null,b=Fe(p.name),x=p.workspacePath??v?.managedWorkspacePath??null,S=St(x,{enabled:!0}).data??[];Q.useEffect(()=>{v&&m(Do(v))},[v]),Q.useEffect(()=>{t===void 0&&r.isSuccess&&s&&s!==`new`&&!v&&c(null)},[t,c,v,s,r.isSuccess]),Q.useEffect(()=>{s!==`new`||d<=_.current||(_.current=d,m(Eo(a?.assistants.length?``:wo)),window.requestAnimationFrame(()=>document.getElementById(`assistant-name`)?.focus()))},[d,s,a?.assistants.length]),Q.useEffect(()=>{r.isSuccess&&i.data?.serverInstanceID&&l?.serverInstanceID===i.data.serverInstanceID&&!a?.assistants.some(e=>e.id===l.assistantID)&&u(null)},[i.data,l,u,a?.assistants,r.isSuccess]),Q.useEffect(()=>{r.isSuccess&&Ie()},[a?.revision,r.isSuccess]);let C=(e,t)=>{m(n=>({...n,[e]:t}))},w=Ae(()=>f()),T=Ae(async()=>{if(!(t!==void 0&&!v)){if(!p.name.trim()||!p.providerID||!p.modelID){Oe.error(n(`assistants.settings.validation.required`));return}g(!0);try{let e=v?await He(v,Oo(p)):await Ue(p);t===void 0&&c(e.id),Oe.success(n(`assistants.settings.toast.saved`))}catch{Oe.error(n(`assistants.settings.toast.saveFailed`))}finally{g(!1)}}}),E=Ae(async()=>{if(!(!v||!window.confirm(n(`assistants.settings.deleteConfirm`,{name:v.name})))){g(!0);try{if(await ze(v),l?.assistantID===v.id){let e=await Ge();e.serverInstanceID&&l.serverInstanceID===e.serverInstanceID&&u(null)}t===void 0&&c(null),e?.(),Oe.success(n(`assistants.settings.toast.deleted`))}catch{Oe.error(n(`assistants.settings.toast.deleteFailed`))}finally{g(!1)}}}),D=Ae(async(e,t)=>{if(!t){u(null),Le();return}try{let t=await Ge();if(!t.supported||!t.serverInstanceID)return;u({serverInstanceID:t.serverInstanceID,assistantID:e}),await Le()}catch{Oe.error(n(`assistants.settings.toast.toggleFailed`))}}),O=p.workspacePath===null?null:o.find(e=>e.path===p.workspacePath)??null,k=p.workspacePath!==null&&!O?p.workspacePath:null,A=p.workspacePath===null?So:O?O.id:Co,j=p.workspacePath===null?(0,$.jsx)(Lo,{name:n(`assistants.settings.workspacePlaceholder`),icon:`cloud`}):O?(0,$.jsx)(Lo,{name:ko(O),path:O.path}):(0,$.jsx)(Lo,{name:n(`assistants.settings.workspaceCurrentPath`),path:k??``,icon:`history`});return i.isSuccess&&!i.data.supported?null:r.isPending||i.isPending?(0,$.jsxs)(`div`,{className:`flex h-full items-center justify-center text-muted-foreground`,children:[(0,$.jsx)(X,{name:`loader-4`,className:`mr-2 size-4 animate-spin`}),n(`common.loading`)]}):r.isError&&!a||t!==void 0&&!v?(0,$.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 px-6 text-center`,children:[(0,$.jsx)(X,{name:`cloud-off`,className:`size-6 text-muted-foreground`}),(0,$.jsx)(`p`,{className:`typography-ui text-muted-foreground`,children:n(`assistants.state.unavailable`)}),(0,$.jsx)(J,{variant:`outline`,size:`sm`,onClick:()=>void r.refetch(),children:n(`assistants.actions.retry`)})]}):(0,$.jsx)(Sr,{outerClassName:`h-full`,className:`w-full`,children:(0,$.jsxs)(`div`,{className:`oc-settings-page-content mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8`,children:[r.isError&&a?(0,$.jsx)(`p`,{className:`mb-4 px-2 typography-meta text-[var(--status-warning)]`,children:n(`assistants.state.staleSnapshot`)}):null,s?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`mb-4 flex items-center gap-3`,children:[(0,$.jsx)($t,{name:v?.id??`new`,emoji:b.avatarEmoji,size:38,label:b.displayName||p.name||n(`assistants.settings.create`),shape:`circle`}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`h2`,{className:`truncate typography-ui-header font-semibold text-foreground`,children:v?y?.displayName:n(`assistants.settings.create`)}),p.providerID&&p.modelID?(0,$.jsx)(`p`,{className:`mt-0.5 typography-micro leading-none text-muted-foreground/70`,children:`${p.providerID}/${p.modelID}`}):null]}),v?(0,$.jsxs)(J,{variant:`ghost`,size:`sm`,onClick:E,disabled:h,className:`text-[var(--status-error)]`,children:[(0,$.jsx)(X,{name:`delete-bin`,className:`size-4`}),n(`assistants.settings.delete`)]}):null]}),(0,$.jsxs)(vi,{children:[(0,$.jsx)(Nr,{itemId:`assistants.name`,label:n(`assistants.settings.name`),children:(0,$.jsx)(fn,{id:`assistant-name`,value:p.name,onChange:e=>C(`name`,e.target.value),className:`min-w-0 flex-1`})}),(0,$.jsx)(Nr,{label:n(`assistants.settings.enabled`),children:(0,$.jsx)(sn,{checked:p.enabled,onChange:e=>C(`enabled`,e),ariaLabel:n(`assistants.settings.enabled`)})}),v?(0,$.jsx)(Nr,{itemId:`assistants.default-share`,label:n(`assistants.settings.defaultShare`),children:(0,$.jsx)(sn,{checked:l?.assistantID===v.id&&l.serverInstanceID===i.data?.serverInstanceID,onChange:e=>void D(v.id,e),ariaLabel:n(`assistants.settings.defaultShare`)})}):null]}),(0,$.jsx)(Jr,{itemId:`assistants.prompt`,label:n(`assistants.settings.defaultPrompt`),className:`oc-settings-split-row-stacked`,children:(0,$.jsx)(Cr,{embedded:!0,id:`assistant-prompt`,value:p.defaultPrompt,onChange:e=>C(`defaultPrompt`,e.target.value),placeholder:n(`assistants.settings.defaultPromptPlaceholder`),rows:12,outerClassName:`min-h-[240px] max-h-[70vh]`})}),(0,$.jsx)(vi,{label:n(`assistants.settings.runtime`),children:(0,$.jsx)(Nr,{itemId:`assistants.model`,label:n(`assistants.settings.model`),children:(0,$.jsx)(Tn,{providerId:p.providerID,modelId:p.modelID,variant:p.variant??``,providers:S,onChange:(e,t,n)=>m(r=>({...r,providerID:e,modelID:t,variant:n||null})),className:`oc-settings-inline-value`})})}),(0,$.jsx)(Jr,{itemId:`assistants.workspace`,label:n(`assistants.settings.workspace`),description:n(`assistants.settings.workspaceChangeHint`),descriptionPlacement:`outside`,children:(0,$.jsxs)(ln,{value:A,onValueChange:e=>{if(e===So){C(`workspacePath`,null);return}let t=o.find(t=>t.id===e);t&&C(`workspacePath`,t.path)},children:[(0,$.jsx)(rn,{title:p.workspacePath??n(`assistants.settings.workspacePlaceholder`),className:`w-full max-w-xl [&_[data-slot=select-value]]:min-w-0 [&_[data-slot=select-value]]:flex-1 [&_[data-slot=select-value]]:overflow-hidden`,children:(0,$.jsx)(dn,{children:j})}),(0,$.jsxs)(an,{align:`start`,className:`w-[min(32rem,calc(100vw-2rem))]`,children:[(0,$.jsx)(tn,{value:So,children:(0,$.jsx)(Lo,{name:n(`assistants.settings.workspacePlaceholder`),icon:`cloud`})}),o.map(e=>(0,$.jsx)(tn,{value:e.id,children:(0,$.jsx)(Lo,{name:ko(e),path:e.path})},e.id)),k?(0,$.jsx)(tn,{value:Co,disabled:!0,children:(0,$.jsx)(Lo,{name:n(`assistants.settings.workspaceCurrentPath`),path:k,icon:`history`})}):null]})]})}),v?(0,$.jsx)(Io,{assistantID:v.id}):null,(0,$.jsx)(`div`,{className:`flex justify-end`,children:(0,$.jsxs)(J,{onClick:T,disabled:h,children:[h?(0,$.jsx)(X,{name:`loader-4`,className:`size-4 animate-spin`}):null,n(`assistants.settings.save`)]})})]}):(0,$.jsxs)(`div`,{className:`flex min-h-80 flex-col items-center justify-center gap-3 px-6 text-center text-muted-foreground`,children:[(0,$.jsx)($t,{name:`assistants-empty`,size:44,shape:`circle`}),(0,$.jsx)(`p`,{className:`typography-ui`,children:n(`assistants.settings.empty`)}),(0,$.jsxs)(J,{"data-settings-item":`assistants.create`,size:`sm`,onClick:w,children:[(0,$.jsx)(X,{name:`add`,className:`size-4`}),n(`assistants.settings.create`)]})]})]})})};function Bo(e){return Mo(e.task)?[{projectId:e.projectID,task:e.task}]:[]}function Vo(e){return!Mo(e.task)}function Ho(e,t){return e.task.enabled===t.task.enabled?e.task.name.localeCompare(t.task.name):e.task.enabled?-1:1}function Uo(){K.getState().setActiveMainTab(`schedule`),K.getState().setScheduledTasksDialogOpen(!0)}var Wo=`~/.config/opencode/AGENTS.md`,Go=async(e,t)=>{let n=await e.json().catch(()=>null);return typeof n?.error==`string`&&n.error.trim()?n.error:t},Ko=e=>e.length>0&&!e.endsWith(`
|
|
2
|
+
`)?`${e}\n`:e,qo={prompt:``,responseStyleEnabled:!1,responseStylePreset:`concise`,responseStyleCustomInstructions:``},Jo=(e,t)=>e===`custom`?t:Vt(e),Yo=e=>e===`custom`?`custom`:kt(e)?e:`concise`,Xo={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`},Zo=async(e,t)=>{let n=await l(`/api/config/settings`,{method:`PUT`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify(e)});if(!n.ok)throw Error(await Go(n,t));return n.json().catch(()=>null)},Qo=()=>{let{t:e}=Me(),t=Q.useSyncExternalStore(r,i,i),[n,a]=Q.useState(``),[o,s]=Q.useState(qo.responseStyleEnabled),[c,u]=Q.useState(qo.responseStylePreset),[d,f]=Q.useState(qo.responseStyleCustomInstructions),[p,m]=Q.useState(!1),[h,g]=Q.useState(!1),[_,v]=Q.useState(!1),[y,b]=Q.useState(``),x=Q.useRef(null),S=Q.useRef(null),w=Q.useRef(0),T=Q.useRef(Promise.resolve());Q.useEffect(()=>{let e=!0;return g(!1),x.current=null,S.current=null,w.current+=1,D(t).then(n=>{if(!e||t!==i())return;let r={enabled:n.responseStyleEnabled===!0,preset:Yo(n.responseStylePreset),custom:typeof n.responseStyleCustomInstructions==`string`?n.responseStyleCustomInstructions:``};s(r.enabled),u(r.preset),f(r.custom),Ft({enabled:r.enabled,preset:r.preset,customInstructions:r.custom},t),x.current=r,S.current=r,g(!0)}).catch(t=>{e&&t?.name!==`AbortError`&&console.warn(`Failed to load behavior settings:`,t)}),()=>{e=!1,w.current+=1}},[t]),Q.useEffect(()=>{let e=new AbortController,n=!0;return m(!1),v(!1),(async()=>{try{let r=await l(`/api/behavior/agents-md`,{method:`GET`,headers:{Accept:`application/json`},signal:e.signal});if(!r.ok)throw Error(`Behavior prompt request failed (${r.status})`);let o=await r.json().catch(()=>null);if(typeof o?.content!=`string`)throw Error(`Invalid behavior prompt response`);if(!n||t!==i())return;a(o.content),b(o.content),m(!0)}catch(e){n&&e?.name!==`AbortError`&&console.warn(`Failed to load behavior prompt:`,e)}})(),()=>{n=!1,e.abort()}},[t]),Q.useEffect(()=>{if(!h)return;let n={enabled:o,preset:c,custom:d},r=S.current;if(r&&r.enabled===n.enabled&&r.preset===n.preset&&r.custom===n.custom)return;S.current=n;let a=w.current+1;w.current=a;let l=setTimeout(()=>{let r=async()=>{if(t===i())try{let r=await Zo({responseStyleEnabled:n.enabled,responseStylePreset:n.preset,responseStyleCustomInstructions:n.custom},e(`settings.behavior.page.toast.saveFailed`));if(t!==i())return;let o=A(r),c={enabled:o.responseStyleEnabled??n.enabled,preset:o.responseStylePreset??n.preset,custom:o.responseStyleCustomInstructions??n.custom};if(Ft({enabled:c.enabled,preset:c.preset,customInstructions:c.custom},t),C({responseStyleEnabled:c.enabled,responseStylePreset:c.preset,responseStyleCustomInstructions:c.custom},t),x.current=c,a!==w.current)return;S.current=c,s(c.enabled),u(c.preset),f(c.custom)}catch(n){if(t===i()&&a===w.current){let t=x.current;S.current=t,t&&(s(t.enabled),u(t.preset),f(t.custom));let r=n instanceof Error?n.message:e(`settings.behavior.page.toast.saveFailed`);Y.error(r)}}};T.current=T.current.then(r,r)},400);return()=>clearTimeout(l)},[o,c,d,h,e,t]);let E=Jo(c,d),O=n!==y;return(0,$.jsx)(Sr,{outerClassName:`h-full`,className:`w-full`,children:(0,$.jsxs)(`div`,{className:`oc-settings-page-content mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8`,children:[(0,$.jsx)(`div`,{className:`space-y-1`,children:(0,$.jsx)(`h2`,{className:`typography-ui-header font-semibold text-foreground`,children:e(`settings.behavior.page.title`)})}),(0,$.jsx)(vi,{itemId:`behavior.system-prompt`,label:(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{children:e(`settings.behavior.page.section.systemPrompt`)}),(0,$.jsxs)(hn,{children:[(0,$.jsx)(pn,{asChild:!0,children:(0,$.jsx)(X,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(mn,{sideOffset:8,className:`max-w-xs`,children:(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`p`,{className:`font-medium text-foreground`,children:e(`settings.behavior.page.warning.title`)}),(0,$.jsx)(`p`,{children:e(`settings.behavior.page.warning.description`,{path:Wo})})]})})]})]}),children:(0,$.jsxs)(`div`,{className:`oc-settings-group-row flex flex-col gap-3`,children:[(0,$.jsx)(Cr,{embedded:!0,value:n,onChange:e=>a(e.target.value),placeholder:e(`settings.behavior.page.field.systemPromptPlaceholder`),rows:12,disabled:!p,outerClassName:`min-h-[160px] max-h-[70vh]`,className:`w-full font-mono typography-meta bg-transparent`}),(0,$.jsx)(J,{onClick:async()=>{let r=t;if(r===i()){v(!0);try{let t=Ko(n),o=await l(`/api/behavior/agents-md`,{method:`PUT`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({content:t})});if(!o.ok)throw Error(await Go(o,e(`settings.behavior.page.toast.saveFailed`)));if(r!==i()||(await Zo({globalBehaviorPrompt:t},e(`settings.behavior.page.toast.saveFailed`)),r!==i()))return;a(t),b(t),Y.success(e(`settings.behavior.page.toast.saved`))}catch(t){if(r!==i())return;console.error(`Failed to save behavior:`,t);let n=t instanceof Error?t.message:e(`settings.behavior.page.toast.saveFailed`);Y.error(n)}finally{r===i()&&v(!1)}}},disabled:_||!O||!p,size:`xs`,className:`!font-normal`,children:e(_?`settings.common.actions.saving`:`settings.common.actions.saveChanges`)})]})}),(0,$.jsxs)(vi,{itemId:`behavior.response-style`,label:(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{children:e(`settings.behavior.page.section.responseStyle`)}),(0,$.jsxs)(hn,{children:[(0,$.jsx)(pn,{asChild:!0,children:(0,$.jsx)(X,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(mn,{sideOffset:8,className:`max-w-xs`,children:e(`settings.behavior.page.responseStyle.tooltip`)})]})]}),children:[(0,$.jsxs)(Nr,{label:e(`settings.behavior.page.responseStyle.enable`),children:[(0,$.jsx)(sn,{checked:o,onChange:s,disabled:!h,ariaLabel:e(`settings.behavior.page.responseStyle.enableAria`)}),(0,$.jsxs)(ln,{value:c,onValueChange:e=>u(e),disabled:!h||!o,children:[(0,$.jsx)(rn,{className:`w-full sm:w-56`,children:(0,$.jsx)(dn,{children:t=>t===`custom`?e(`settings.behavior.page.responseStyle.option.custom`):kt(t)?e(Xo[t]):null})}),(0,$.jsxs)(an,{children:[Dt.map(t=>(0,$.jsx)(tn,{value:t,children:e(Xo[t])},t)),(0,$.jsx)(tn,{value:`custom`,children:e(`settings.behavior.page.responseStyle.option.custom`)})]})]})]}),(0,$.jsx)(`div`,{className:`oc-settings-group-row`,children:(0,$.jsx)(Cr,{embedded:!0,value:E,onChange:e=>f(e.target.value),placeholder:e(`settings.behavior.page.responseStyle.customPlaceholder`),rows:5,disabled:!h||!o||c!==`custom`,outerClassName:`min-h-[120px]`,className:`w-full font-mono typography-meta bg-transparent`})})]})]})})},$o=e=>{let t=(0,Ii.c)(158),{onItemSelect:n}=e,{t:r}=Me(),[i,a]=Q.useState(null),[o,s]=Q.useState(``),[c,l]=Q.useState(null),[u,d]=Q.useState(null),[f,p]=Q.useState(!1),[m,h]=Q.useState(null),{selectedCommandName:g,setSelectedCommand:_,setCommandDraft:v,createCommand:y,deleteCommand:b}=ra(le(ts)),x=ot(),S;t[0]===x.data?S=t[1]:(S=x.data??[],t[0]=x.data,t[1]=S);let C=S,w=ft(),T;t[2]===w.data?T=t[3]:(T=w.data??[],t[2]=w.data,t[3]=T);let E=T,{refetch:D}=w,O,k;t[4]===D?(O=t[5],k=t[6]):(O=()=>{D()},k=[D],t[4]=D,t[5]=O,t[6]=k),Q.useEffect(O,k);let A;t[7]===E?A=t[8]:(A=new Set(E.map(ns)),t[7]=E,t[8]=A);let j=A,M;if(t[9]!==C||t[10]!==j){let e;t[12]===j?e=t[13]:(e=e=>!j.has(e.name),t[12]=j,t[13]=e),M=C.filter(e),t[9]=C,t[10]=j,t[11]=M}else M=t[11];let N=M,P,F;t[14]!==g||t[15]!==_||t[16]!==j?(P=()=>{g&&j.has(g)&&_(null)},F=[g,_,j],t[14]=g,t[15]=_,t[16]=j,t[17]=P,t[18]=F):(P=t[17],F=t[18]),Q.useEffect(P,F);let I;t[19]!==C||t[20]!==n||t[21]!==v||t[22]!==_?(I=()=>{let e=`new-command`,t=1;for(;C.some(t=>t.name===e);)e=`new-command-${t}`,t++;v({name:e,scope:`user`}),_(e),n?.()},t[19]=C,t[20]=n,t[21]=v,t[22]=_,t[23]=I):I=t[23];let L=I,R;t[24]===r?R=t[25]:(R=async e=>{if(ta(e)){Y.error(r(`settings.commands.sidebar.toast.builtInCannotDelete`));return}l(e),d(`delete`)},t[24]=r,t[25]=R);let z=R,B;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(B=async e=>{ta(e)&&(l(e),d(`reset`))},t[26]=B):B=t[26];let V=B,H;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(H=()=>{l(null),d(null)},t[27]=H):H=t[27];let U=H,W;t[28]!==c||t[29]!==u||t[30]!==b||t[31]!==r?(W=async()=>{!c||!u||(p(!0),await b(c.name)?(u===`delete`?Y.success(r(`settings.commands.sidebar.toast.commandDeleted`,{name:c.name})):Y.success(r(`settings.commands.sidebar.toast.commandReset`,{name:c.name})),U()):u===`delete`?Y.error(r(`settings.commands.sidebar.toast.deleteFailed`)):Y.error(r(`settings.commands.sidebar.toast.resetFailed`)),p(!1))},t[28]=c,t[29]=u,t[30]=b,t[31]=r,t[32]=W):W=t[32];let ee=W,G;t[33]!==C||t[34]!==v||t[35]!==_?(G=e=>{let t=e.name,n=1,r=`${t}-copy`;for(;C.some(e=>e.name===r);)n++,r=`${t}-copy-${n}`;v({name:r,scope:e.scope||`user`,description:e.description,template:e.template,agent:e.agent,model:e.model}),_(r)},t[33]=C,t[34]=v,t[35]=_,t[36]=G):G=t[36];let te=G,ne;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(ne=e=>{s(e.name),a(e)},t[37]=ne):ne=t[37];let re=ne,ie;t[38]!==C||t[39]!==y||t[40]!==b||t[41]!==i||t[42]!==o||t[43]!==_||t[44]!==r?(ie=async()=>{if(!i)return;let e=o.trim().replace(/\s+/g,`-`);if(!e){Y.error(r(`settings.commands.sidebar.toast.commandNameRequired`));return}if(e===i.name){a(null);return}if(C.some(t=>t.name===e)){Y.error(r(`settings.commands.sidebar.toast.commandExists`));return}await y({name:e,description:i.description,template:i.template,agent:i.agent,model:i.model})?await b(i.name)?(Y.success(`Command renamed to "${e}"`),_(e)):Y.error(r(`settings.commands.sidebar.toast.removeOldAfterRenameFailed`)):Y.error(r(`settings.commands.sidebar.toast.renameFailed`)),a(null)},t[38]=C,t[39]=y,t[40]=b,t[41]=i,t[42]=o,t[43]=_,t[44]=r,t[45]=ie):ie=t[45];let ae=ie,oe,se,ce;if(t[46]!==N||t[47]!==L||t[48]!==z||t[49]!==te||t[50]!==n||t[51]!==m||t[52]!==g||t[53]!==_||t[54]!==r){let e=N.filter(ta),i=N.filter(rs),a;t[58]===r?a=t[59]:(a=r(`settings.commands.sidebar.section.custom`),t[58]=r,t[59]=a);let o;t[60]===a?o=t[61]:(o=(0,$.jsx)(`span`,{children:a}),t[60]=a,t[61]=o);let s;t[62]===r?s=t[63]:(s=r(`settings.commands.page.title.new`),t[62]=r,t[63]=s);let c;t[64]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(X,{name:`add`,className:`h-4 w-4`}),t[64]=c):c=t[64];let l;t[65]!==L||t[66]!==s?(l=(0,$.jsx)(J,{"data-settings-item":`commands.create`,size:`icon`,variant:`ghost`,onClick:L,"aria-label":s,children:c}),t[65]=L,t[66]=s,t[67]=l):l=t[67];let u;t[68]!==o||t[69]!==l?(u=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[o,l]}),t[68]=o,t[69]=l,t[70]=u):u=t[70];let d=u;oe=`oc-settings-page-content h-full overflow-y-auto bg-background p-3`,t[71]===Symbol.for(`react.memo_cache_sentinel`)?(se=(0,$.jsx)(vi,{children:(0,$.jsx)(`div`,{className:`oc-settings-group-row`,children:(0,$.jsx)(ja,{})})}),t[71]=se):se=t[71],ce=(0,$.jsx)($.Fragment,{children:N.length===0?(0,$.jsx)(vi,{label:d,children:(0,$.jsxs)(`div`,{className:`oc-settings-group-row py-12 text-center text-muted-foreground`,children:[(0,$.jsx)(X,{name:`terminal-box`,className:`mx-auto mb-3 h-10 w-10 opacity-50`}),(0,$.jsx)(`p`,{className:`typography-ui-label font-medium`,children:r(`settings.commands.sidebar.empty.title`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 opacity-75`,children:r(`settings.commands.sidebar.empty.description`)})]})}):(0,$.jsxs)($.Fragment,{children:[e.length>0&&(0,$.jsx)(vi,{label:r(`settings.commands.sidebar.section.builtIn`),children:[...e].sort(is).map(e=>(0,$.jsx)(es,{command:e,isSelected:g===e.name,onSelect:()=>{_(e.name),n?.()},onReset:()=>V(e),onDuplicate:()=>te(e),isMenuOpen:m===e.name,onMenuOpenChange:t=>h(t?e.name:null)},e.name))}),i.length>0?(0,$.jsx)(vi,{label:d,children:[...i].sort(as).map(e=>(0,$.jsx)(es,{command:e,isSelected:g===e.name,onSelect:()=>{_(e.name),n?.()},onRename:()=>re(e),onDelete:()=>z(e),onDuplicate:()=>te(e),isMenuOpen:m===e.name,onMenuOpenChange:t=>h(t?e.name:null)},e.name))}):(0,$.jsx)(vi,{label:d,cardClassName:`hidden`,children:(0,$.jsx)(`span`,{})})]})}),t[46]=N,t[47]=L,t[48]=z,t[49]=te,t[50]=n,t[51]=m,t[52]=g,t[53]=_,t[54]=r,t[55]=oe,t[56]=se,t[57]=ce}else oe=t[55],se=t[56],ce=t[57];let ue=c!==null&&u!==null,de;t[72]===f?de=t[73]:(de=e=>{!e&&!f&&U()},t[72]=f,t[73]=de);let fe;t[74]!==u||t[75]!==r?(fe=r(u===`delete`?`settings.commands.sidebar.dialog.deleteTitle`:`settings.commands.sidebar.dialog.resetTitle`),t[74]=u,t[75]=r,t[76]=fe):fe=t[76];let pe;t[77]===fe?pe=t[78]:(pe=(0,$.jsx)(Xt,{children:fe}),t[77]=fe,t[78]=pe);let me;t[79]!==c?.name||t[80]!==u||t[81]!==r?(me=r(u===`delete`?`settings.commands.sidebar.dialog.deleteDescription`:`settings.commands.sidebar.dialog.resetDescription`,{name:c?.name??``}),t[79]=c?.name,t[80]=u,t[81]=r,t[82]=me):me=t[82];let he;t[83]===me?he=t[84]:(he=(0,$.jsx)(Zt,{children:me}),t[83]=me,t[84]=he);let ge;t[85]!==pe||t[86]!==he?(ge=(0,$.jsxs)(qt,{children:[pe,he]}),t[85]=pe,t[86]=he,t[87]=ge):ge=t[87];let _e;t[88]===r?_e=t[89]:(_e=r(`settings.common.actions.cancel`),t[88]=r,t[89]=_e);let ve;t[90]!==f||t[91]!==_e?(ve=(0,$.jsx)(J,{size:`sm`,variant:`ghost`,onClick:U,disabled:f,children:_e}),t[90]=f,t[91]=_e,t[92]=ve):ve=t[92];let K;t[93]!==u||t[94]!==r?(K=r(u===`delete`?`settings.common.actions.delete`:`settings.common.actions.reset`),t[93]=u,t[94]=r,t[95]=K):K=t[95];let ye;t[96]!==ee||t[97]!==f||t[98]!==K?(ye=(0,$.jsx)(J,{size:`sm`,onClick:ee,disabled:f,children:K}),t[96]=ee,t[97]=f,t[98]=K,t[99]=ye):ye=t[99];let be;t[100]!==ve||t[101]!==ye?(be=(0,$.jsxs)(Jt,{children:[ve,ye]}),t[100]=ve,t[101]=ye,t[102]=be):be=t[102];let xe;t[103]!==ge||t[104]!==be?(xe=(0,$.jsxs)(Yt,{className:`max-w-md`,children:[ge,be]}),t[103]=ge,t[104]=be,t[105]=xe):xe=t[105];let Se;t[106]!==ue||t[107]!==de||t[108]!==xe?(Se=(0,$.jsx)(Qt,{open:ue,onOpenChange:de,children:xe}),t[106]=ue,t[107]=de,t[108]=xe,t[109]=Se):Se=t[109];let Ce=i!==null,we;t[110]===Symbol.for(`react.memo_cache_sentinel`)?(we=e=>!e&&a(null),t[110]=we):we=t[110];let Te;t[111]===r?Te=t[112]:(Te=r(`settings.commands.sidebar.renameDialog.title`),t[111]=r,t[112]=Te);let Ee;t[113]===Te?Ee=t[114]:(Ee=(0,$.jsx)(Xt,{children:Te}),t[113]=Te,t[114]=Ee);let De=i?.name??``,Oe;t[115]!==r||t[116]!==De?(Oe=r(`settings.commands.sidebar.renameDialog.description`,{name:De}),t[115]=r,t[116]=De,t[117]=Oe):Oe=t[117];let ke;t[118]===Oe?ke=t[119]:(ke=(0,$.jsx)(Zt,{children:Oe}),t[118]=Oe,t[119]=ke);let Ae;t[120]!==Ee||t[121]!==ke?(Ae=(0,$.jsxs)(qt,{children:[Ee,ke]}),t[120]=Ee,t[121]=ke,t[122]=Ae):Ae=t[122];let je;t[123]===Symbol.for(`react.memo_cache_sentinel`)?(je=e=>s(e.target.value),t[123]=je):je=t[123];let Ne;t[124]===r?Ne=t[125]:(Ne=r(`settings.commands.sidebar.renameDialog.placeholder`),t[124]=r,t[125]=Ne);let Pe;t[126]===ae?Pe=t[127]:(Pe=e=>{e.key===`Enter`&&ae()},t[126]=ae,t[127]=Pe);let q;t[128]!==o||t[129]!==Ne||t[130]!==Pe?(q=(0,$.jsx)(fn,{value:o,onChange:je,placeholder:Ne,className:`text-foreground placeholder:text-muted-foreground`,onKeyDown:Pe}),t[128]=o,t[129]=Ne,t[130]=Pe,t[131]=q):q=t[131];let Fe;t[132]===Symbol.for(`react.memo_cache_sentinel`)?(Fe=()=>a(null),t[132]=Fe):Fe=t[132];let Ie;t[133]===r?Ie=t[134]:(Ie=r(`settings.common.actions.cancel`),t[133]=r,t[134]=Ie);let Le;t[135]===Ie?Le=t[136]:(Le=(0,$.jsx)(J,{size:`sm`,variant:`ghost`,onClick:Fe,children:Ie}),t[135]=Ie,t[136]=Le);let Re;t[137]===r?Re=t[138]:(Re=r(`settings.common.actions.rename`),t[137]=r,t[138]=Re);let ze;t[139]!==ae||t[140]!==Re?(ze=(0,$.jsx)(J,{size:`sm`,onClick:ae,children:Re}),t[139]=ae,t[140]=Re,t[141]=ze):ze=t[141];let Be;t[142]!==Le||t[143]!==ze?(Be=(0,$.jsxs)(Jt,{children:[Le,ze]}),t[142]=Le,t[143]=ze,t[144]=Be):Be=t[144];let Ve;t[145]!==Ae||t[146]!==q||t[147]!==Be?(Ve=(0,$.jsxs)(Yt,{children:[Ae,q,Be]}),t[145]=Ae,t[146]=q,t[147]=Be,t[148]=Ve):Ve=t[148];let He;t[149]!==Ce||t[150]!==Ve?(He=(0,$.jsx)(Qt,{open:Ce,onOpenChange:we,children:Ve}),t[149]=Ce,t[150]=Ve,t[151]=He):He=t[151];let Ue;return t[152]!==oe||t[153]!==se||t[154]!==ce||t[155]!==Se||t[156]!==He?(Ue=(0,$.jsxs)(`div`,{className:oe,children:[se,ce,Se,He]}),t[152]=oe,t[153]=se,t[154]=ce,t[155]=Se,t[156]=He,t[157]=Ue):Ue=t[157],Ue},es=e=>{let t=(0,Ii.c)(47),{command:n,isSelected:r,onSelect:i,onDelete:a,onReset:o,onRename:s,onDuplicate:c,isMenuOpen:l,onMenuOpenChange:u}=e,{t:d}=Me(),f;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(f=br(),t[0]=f):f=t[0];let p=f,[m,h]=Q.useState(!1),g;t[1]!==a||t[2]!==c||t[3]!==s||t[4]!==o||t[5]!==d?(g=e=>(0,$.jsxs)($.Fragment,{children:[s&&(0,$.jsxs)(e,{onClick:e=>{e.stopPropagation(),s()},children:[(0,$.jsx)(X,{name:`edit`,className:`h-4 w-4 mr-px`}),d(`settings.common.actions.rename`)]}),(0,$.jsxs)(e,{onClick:e=>{e.stopPropagation(),c()},children:[(0,$.jsx)(X,{name:`file-copy`,className:`h-4 w-4 mr-px`}),d(`settings.common.actions.duplicate`)]}),o&&(0,$.jsxs)(e,{onClick:e=>{e.stopPropagation(),o()},children:[(0,$.jsx)(X,{name:`restart`,className:`h-4 w-4 mr-px`}),d(`settings.common.actions.reset`)]}),a&&(0,$.jsxs)(e,{onClick:e=>{e.stopPropagation(),a()},className:`text-destructive focus:text-destructive`,children:[(0,$.jsx)(X,{name:`delete-bin`,className:`h-4 w-4 mr-px`}),d(`settings.common.actions.delete`)]})]}),t[1]=a,t[2]=c,t[3]=s,t[4]=o,t[5]=d,t[6]=g):g=t[6];let _=g,v=r?`bg-interactive-selection`:`hover:bg-interactive-hover`,y;t[7]===v?y=t[8]:(y=q(`oc-settings-group-row group relative flex items-center transition-colors duration-150 select-none`,v),t[7]=v,t[8]=y);let b;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(b=p?void 0:e=>{e.preventDefault(),h(!0)},t[9]=b):b=t[9];let x;t[10]===y?x=t[11]:(x=(0,$.jsx)(`div`,{className:y,onContextMenu:b}),t[10]=y,t[11]=x);let S;t[12]===n.name?S=t[13]:(S=(0,$.jsxs)(`span`,{className:`typography-ui-label font-normal truncate text-foreground`,children:[`/`,n.name]}),t[12]=n.name,t[13]=S);let C;t[14]!==n||t[15]!==d?(C=(n.scope||ta(n))&&(0,$.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:ta(n)?d(`settings.agents.sidebar.badge.system`):n.scope}),t[14]=n,t[15]=d,t[16]=C):C=t[16];let w;t[17]!==S||t[18]!==C?(w=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[S,C]}),t[17]=S,t[18]=C,t[19]=w):w=t[19];let T;t[20]===n.description?T=t[21]:(T=n.description&&(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground/60 truncate leading-tight`,children:n.description}),t[20]=n.description,t[21]=T);let E;t[22]!==i||t[23]!==T||t[24]!==w?(E=(0,$.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:[w,T]}),t[22]=i,t[23]=T,t[24]=w,t[25]=E):E=t[25];let D;t[26]===u?D=t[27]:(D=e=>{e&&h(!1),u(e)},t[26]=u,t[27]=D);let O;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,$.jsx)(mr,{asChild:!0,children:(0,$.jsx)(J,{size:`sm`,variant:`ghost`,className:`h-6 w-6 px-0 flex-shrink-0 -mr-1 opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100`,children:(0,$.jsx)(X,{name:`more-2`,className:`h-3.5 w-3.5`})})}),t[28]=O):O=t[28];let k;t[29]===_?k=t[30]:(k=(0,$.jsx)(Qn,{align:`end`,className:`w-fit min-w-20`,children:_(Wn)}),t[29]=_,t[30]=k);let A;t[31]!==l||t[32]!==D||t[33]!==k?(A=(0,$.jsxs)(cr,{open:l,onOpenChange:D,children:[O,k]}),t[31]=l,t[32]=D,t[33]=k,t[34]=A):A=t[34];let j;t[35]!==E||t[36]!==A?(j=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center`,children:[E,A]}),t[35]=E,t[36]=A,t[37]=j):j=t[37];let M;t[38]!==j||t[39]!==x?(M=(0,$.jsx)(Ei,{render:x,children:j}),t[38]=j,t[39]=x,t[40]=M):M=t[40];let N;t[41]===_?N=t[42]:(N=(0,$.jsx)(Di,{className:`w-fit min-w-20`,children:_(Oi)}),t[41]=_,t[42]=N);let P;return t[43]!==m||t[44]!==M||t[45]!==N?(P=(0,$.jsxs)(ki,{open:m,onOpenChange:h,children:[M,N]}),t[43]=m,t[44]=M,t[45]=N,t[46]=P):P=t[46],P};function ts(e){return{selectedCommandName:e.selectedCommandName,setSelectedCommand:e.setSelectedCommand,setCommandDraft:e.setCommandDraft,createCommand:e.createCommand,deleteCommand:e.deleteCommand}}function ns(e){return e.name}function rs(e){return!ta(e)}function is(e,t){return e.name.localeCompare(t.name)}function as(e,t){return e.name.localeCompare(t.name)}var os=()=>{let{t:e}=Me(),{selectedCommandName:t,createCommand:n,updateCommand:r,commandDraft:i,setCommandDraft:a}=ra(le(e=>({selectedCommandName:e.selectedCommandName,createCommand:e.createCommand,updateCommand:e.updateCommand,commandDraft:e.commandDraft,setCommandDraft:e.setCommandDraft}))),o=ot(),s=Q.useMemo(()=>o.data??[],[o.data]),c=t?s.find(e=>e.name===t):null,l=!!(i&&i.name===t&&!c),[u,d]=Q.useState(``),[f,p]=Q.useState(`user`),[m,h]=Q.useState(``),[g,_]=Q.useState(``),[v,y]=Q.useState(``),[b,x]=Q.useState(``),[S,C]=Q.useState(!1),w=Q.useRef(null);Q.useEffect(()=>{if(l&&i){let e=i.name||``,t=i.scope||`user`,n=i.description||``,r=i.agent||``,a=i.model||``,o=i.template||``;d(e),p(t),h(n),_(r),y(a),x(o),w.current={draftName:e,draftScope:t,description:n,agent:r,model:a,template:o}}else if(c){let e=c.description||``,t=c.agent||``,n=c.model||``,r=c.template||``;h(e),_(t),y(n),x(r),w.current={draftName:``,draftScope:`user`,description:e,agent:t,model:n,template:r}}},[c,l,t,s,i]);let T=Q.useMemo(()=>{let e=w.current;return e?!!(l&&(u!==e.draftName||f!==e.draftScope)||m!==e.description||g!==e.agent||v!==e.model||b!==e.template):!1},[g,m,u,f,l,v,b]);return t?(0,$.jsx)(Sr,{outerClassName:`h-full`,className:`w-full`,children:(0,$.jsxs)(`div`,{className:`oc-settings-page-content mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8`,children:[(0,$.jsx)(`div`,{className:`mb-4 flex items-center justify-between gap-4`,children:(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`h2`,{className:`typography-ui-header font-semibold text-foreground truncate`,children:l?e(`settings.commands.page.title.new`):`/${t}`}),(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground truncate`,children:e(l?`settings.commands.page.subtitle.new`:`settings.commands.page.subtitle.edit`)})]})}),(0,$.jsxs)(vi,{label:e(`settings.commands.page.section.identity`),children:[l&&(0,$.jsxs)(Nr,{itemId:`commands.name`,label:e(`settings.commands.page.field.commandName`),children:[(0,$.jsxs)(`div`,{className:`flex items-center`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-muted-foreground mr-1`,children:`/`}),(0,$.jsx)(fn,{value:u,onChange:e=>d(e.target.value),placeholder:e(`settings.commands.page.field.commandNamePlaceholder`),className:`h-7 w-40 px-2`})]}),(0,$.jsxs)(ln,{value:f,onValueChange:e=>p(e),children:[(0,$.jsx)(rn,{className:`w-fit min-w-[100px]`,children:(0,$.jsx)(dn,{placeholder:e(`settings.agents.page.field.scopePlaceholder`)})}),(0,$.jsxs)(an,{align:`end`,children:[(0,$.jsx)(tn,{value:`user`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(X,{name:`user-3`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:e(`settings.common.scope.global`)})]})}),(0,$.jsx)(tn,{value:`project`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(X,{name:`folder`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:e(`settings.common.scope.project`)})]})})]})]})]}),(0,$.jsx)(Nr,{label:e(`settings.common.field.description`),className:`oc-settings-split-row-stacked`,children:(0,$.jsx)(Cr,{embedded:!0,value:m,onChange:e=>h(e.target.value),placeholder:e(`settings.commands.page.field.descriptionPlaceholder`),rows:2,className:`w-full resize-none min-h-[60px] bg-transparent`})})]}),(0,$.jsxs)(vi,{label:e(`settings.commands.page.section.executionContext`),children:[(0,$.jsx)(Nr,{itemId:`commands.agent`,label:e(`settings.commands.page.field.overrideAgent`),children:(0,$.jsx)(fr,{agentName:g,onChange:e=>_(e),className:`oc-settings-inline-value`})}),(0,$.jsx)(Nr,{itemId:`commands.model`,label:e(`settings.agents.page.field.overrideModel`),children:(0,$.jsx)(Tn,{providerId:Ht(v)?.providerId??``,modelId:Ht(v)?.modelId??``,onChange:(e,t)=>{y(e&&t?`${e}/${t}`:``)},className:`oc-settings-inline-value`})})]}),(0,$.jsx)(Jr,{itemId:`commands.template`,label:e(`settings.commands.page.section.template`),description:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`code`,{className:`text-foreground`,children:`$ARGUMENTS`}),` `,e(`settings.commands.page.templateHint.userInput`),` ·`,` `,(0,$.jsx)(`code`,{className:`text-foreground`,children:"!`cmd`"}),` `,e(`settings.commands.page.templateHint.shellOutput`),` ·`,` `,(0,$.jsx)(`code`,{className:`text-foreground`,children:`@file`}),` `,e(`settings.commands.page.templateHint.fileContents`)]}),descriptionPlacement:`outside`,className:`oc-settings-split-row-stacked`,children:(0,$.jsx)(Cr,{embedded:!0,value:b,onChange:e=>x(e.target.value),placeholder:e(`settings.commands.page.field.templatePlaceholder`),rows:12,className:`w-full font-mono typography-meta min-h-[160px] max-h-[60vh] bg-transparent resize-y`})}),(0,$.jsx)(`div`,{className:`px-2 py-1`,children:(0,$.jsx)(J,{onClick:async()=>{let i=l?u.trim().replace(/\s+/g,`-`):t?.trim();if(!i){Y.error(e(`settings.commands.sidebar.toast.commandNameRequired`));return}if(!b.trim()){Y.error(e(`settings.commands.page.toast.templateRequired`));return}if(l&&s.some(e=>e.name===i)){Y.error(e(`settings.commands.sidebar.toast.commandExists`));return}C(!0);try{let t=g.trim(),o=v.trim(),s=b.trim(),c={name:i,description:m.trim()||void 0,agent:t===``?null:t,model:o===``?null:o,template:s,scope:l?f:void 0},u;l?(u=await n(c),u&&a(null)):u=await r(i,c),u?Y.success(e(l?`settings.commands.page.toast.created`:`settings.commands.page.toast.updated`)):Y.error(e(l?`settings.commands.page.toast.createFailed`:`settings.commands.page.toast.updateFailed`))}catch(t){console.error(`Error saving command:`,t),Y.error(e(`settings.commands.page.toast.saveUnexpectedError`))}finally{C(!1)}},disabled:S||!T,size:`xs`,className:`!font-normal`,children:e(S?`settings.common.actions.saving`:`settings.common.actions.saveChanges`)})})]})}):(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,$.jsxs)(`div`,{className:`text-center text-muted-foreground`,children:[(0,$.jsx)(X,{name:`terminal-box`,className:`mx-auto mb-3 h-12 w-12 opacity-50`}),(0,$.jsx)(`p`,{className:`typography-body`,children:e(`settings.commands.page.empty.title`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 opacity-75`,children:e(`settings.commands.page.empty.description`)})]})})},ss=[],cs=e=>{switch(e){case`connected`:return`success`;case`failed`:return`error`;case`needs_auth`:case`needs_client_registration`:return`warning`;default:return`idle`}},ls=e=>{let t=(0,Ii.c)(5),{tone:n,enabled:r}=e;if(!r){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`span`,{className:`inline-block h-2 w-2 rounded-full bg-muted-foreground/30 flex-shrink-0`}),t[0]=e):e=t[0],e}let i;t[1]===n?i=t[2]:(i=q(`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]),t[1]=n,t[2]=i);let a;return t[3]===i?a=t[4]:(a=(0,$.jsx)(`span`,{className:i}),t[3]=i,t[4]=a),a},us=e=>{let t=(0,Ii.c)(115),{onItemSelect:n}=e,{t:r}=Me(),{selectedMcpName:a,setSelectedMcp:o,setMcpDraft:s,deleteMcp:c}=la(le(ds)),l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=Ti(),t[0]=l):l=t[0];let u=l,d=bi(u),f=Si(u),p=d.data??ss,m;t[1]===f.data?m=t[2]:(m=f.data??{},t[1]=f.data,t[2]=m);let h=m,[g,_]=Q.useState(null),[v,y]=Q.useState(!1),[b,x]=Q.useState(null),[S,C]=Q.useState(null),[T,E]=Q.useState(!1),D;t[3]===p?D=t[4]:(D=p.filter(fs),t[3]=p,t[4]=D);let O=D,k;t[5]===p?k=t[6]:(k=p.filter(ps),t[5]=p,t[6]=k);let A=k,j;t[7]===T?j=t[8]:(j=()=>{if(T)return;E(!0);let e=new Promise(ms),t=i();Promise.all([Ci(w,u,t),e]).catch(hs).finally(()=>{E(!1)})},t[7]=T,t[8]=j);let M=j,N;t[9]!==p||t[10]!==n||t[11]!==s||t[12]!==o?(N=()=>{let e=`new-mcp-server`,t=1;for(;p.some(t=>t.name===e);)e=`new-mcp-server-${t}`,t++;s({name:e,scope:`user`,type:`local`,command:[],url:``,environment:[],headers:[],oauthEnabled:!0,oauthClientId:``,oauthClientSecret:``,oauthScope:``,oauthRedirectUri:``,timeout:``,enabled:!0}),o(e),n?.()},t[9]=p,t[10]=n,t[11]=s,t[12]=o,t[13]=N):N=t[13];let P=N,F;t[14]!==c||t[15]!==g||t[16]!==r?(F=async()=>{if(!g)return;y(!0);let e=await c(g.name,{directory:Ti(),transportIdentity:i()});e.ok?e.reloadFailed?Y.warning(e.message||`MCP server "${g.name}" deleted, but OpenCode reload failed`,{description:e.warning||r(`settings.mcp.sidebar.toast.refreshListIfStale`)}):Y.success(e.message||r(`settings.mcp.sidebar.toast.serverDeleted`,{name:g.name})):Y.error(r(`settings.mcp.sidebar.toast.deleteFailed`)),_(null),y(!1)},t[14]=c,t[15]=g,t[16]=r,t[17]=F):F=t[17];let I=F,L;t[18]===r?L=t[19]:(L=(e,t)=>(0,$.jsxs)(t,{onClick:t=>{t.stopPropagation(),_(e)},className:`text-destructive focus:text-destructive`,children:[(0,$.jsx)(X,{name:`delete-bin`,className:`h-4 w-4 mr-px`}),r(`settings.common.actions.delete`)]}),t[18]=r,t[19]=L);let R=L,z;t[20]===r?z=t[21]:(z=r(`settings.mcp.sidebar.group.userServers`),t[20]=r,t[21]=z);let B;t[22]===z?B=t[23]:(B=(0,$.jsx)(`span`,{children:z}),t[22]=z,t[23]=B);let V;t[24]===r?V=t[25]:(V=r(`settings.mcp.sidebar.actions.refreshStatusAria`),t[24]=r,t[25]=V);let H;t[26]===r?H=t[27]:(H=r(`settings.mcp.sidebar.actions.refreshStatusTitle`),t[26]=r,t[27]=H);let U=T&&`animate-spin`,W;t[28]===U?W=t[29]:(W=q(`h-4 w-4`,U),t[28]=U,t[29]=W);let ee;t[30]===W?ee=t[31]:(ee=(0,$.jsx)(X,{name:`refresh`,className:W}),t[30]=W,t[31]=ee);let G;t[32]!==M||t[33]!==T||t[34]!==V||t[35]!==H||t[36]!==ee?(G=(0,$.jsx)(J,{type:`button`,size:`icon`,variant:`ghost`,disabled:T,onClick:M,"aria-label":V,title:H,children:ee}),t[32]=M,t[33]=T,t[34]=V,t[35]=H,t[36]=ee,t[37]=G):G=t[37];let te;t[38]===r?te=t[39]:(te=r(`settings.mcp.sidebar.actions.addServerTitle`),t[38]=r,t[39]=te);let ne;t[40]===r?ne=t[41]:(ne=r(`settings.mcp.sidebar.actions.addServerTitle`),t[40]=r,t[41]=ne);let re;t[42]===Symbol.for(`react.memo_cache_sentinel`)?(re=(0,$.jsx)(X,{name:`add`,className:`h-4 w-4`}),t[42]=re):re=t[42];let ie;t[43]!==P||t[44]!==te||t[45]!==ne?(ie=(0,$.jsx)(J,{"data-settings-item":`mcp.create`,size:`icon`,variant:`ghost`,onClick:P,"aria-label":te,title:ne,children:re}),t[43]=P,t[44]=te,t[45]=ne,t[46]=ie):ie=t[46];let ae;t[47]!==G||t[48]!==ie?(ae=(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[G,ie]}),t[47]=G,t[48]=ie,t[49]=ae):ae=t[49];let oe;t[50]!==B||t[51]!==ae?(oe=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[B,ae]}),t[50]=B,t[51]=ae,t[52]=oe):oe=t[52];let se=oe,ce;t[53]===Symbol.for(`react.memo_cache_sentinel`)?(ce=(0,$.jsx)(vi,{children:(0,$.jsx)(`div`,{className:`oc-settings-group-row`,children:(0,$.jsx)(ja,{})})}),t[53]=ce):ce=t[53];let ue;t[54]!==d.data||t[55]!==d.error||t[56]!==d.isError||t[57]!==p.length||t[58]!==h||t[59]!==n||t[60]!==b||t[61]!==O||t[62]!==R||t[63]!==S||t[64]!==a||t[65]!==s||t[66]!==o||t[67]!==f.data||t[68]!==f.error||t[69]!==f.isError||t[70]!==r||t[71]!==A||t[72]!==se?(ue=(0,$.jsx)($.Fragment,{children:d.isError&&!d.data?(0,$.jsx)(vi,{label:se,children:(0,$.jsx)(`div`,{className:`oc-settings-group-row py-12 text-center typography-meta text-[var(--status-error)]`,children:d.error.message})}):p.length===0?(0,$.jsx)(vi,{label:se,children:(0,$.jsxs)(`div`,{className:`oc-settings-group-row py-12 text-center text-muted-foreground`,children:[(0,$.jsx)(X,{name:`plug`,className:`mx-auto mb-3 h-10 w-10 opacity-50`}),(0,$.jsx)(`p`,{className:`typography-ui-label font-medium`,children:r(`settings.mcp.sidebar.empty.title`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 opacity-75`,children:r(`settings.mcp.sidebar.empty.description`)})]})}):(0,$.jsxs)($.Fragment,{children:[O.length>0&&(0,$.jsx)(vi,{label:r(`settings.mcp.sidebar.group.projectServers`),children:O.map(e=>{let t=cs((h[e.name]??(f.isError&&!f.data?{status:`failed`,error:f.error.message}:void 0))?.status),i=a===e.name,c=br();return(0,$.jsxs)(ki,{open:S===e.name,onOpenChange:t=>C(t?e.name:null),children:[(0,$.jsxs)(Ei,{render:(0,$.jsx)(`div`,{className:q(`oc-settings-group-row group relative flex items-center transition-colors duration-150 select-none`,i?`bg-interactive-selection`:`hover:bg-interactive-hover`),onContextMenu:c?void 0:t=>{t.preventDefault(),C(e.name)}}),children:[(0,$.jsxs)(`button`,{onClick:()=>{o(e.name),s(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:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(ls,{tone:t,enabled:e.enabled}),(0,$.jsx)(`span`,{className:`typography-ui-label font-normal truncate text-foreground`,children:e.name}),(0,$.jsx)(`span`,{title:e.type===`local`?r(`settings.mcp.sidebar.serverType.localTitle`):r(`settings.mcp.sidebar.serverType.remoteTitle`),children:e.type===`local`?(0,$.jsx)(X,{name:`server`,className:`h-3 w-3 text-muted-foreground/60 flex-shrink-0`}):(0,$.jsx)(X,{name:`global`,className:`h-3 w-3 text-muted-foreground/60 flex-shrink-0`})})]}),(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground/60 truncate leading-tight pl-4`,children:e.type===`local`?e.command?.join(` `)??``:e.url??``})]}),(0,$.jsxs)(cr,{open:b===e.name,onOpenChange:t=>{t&&C(null),x(t?e.name:null)},children:[(0,$.jsx)(mr,{asChild:!0,children:(0,$.jsx)(J,{size:`xs`,variant:`ghost`,className:`flex-shrink-0 -mr-1 opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100`,children:(0,$.jsx)(X,{name:`more-2`,className:`h-3.5 w-3.5`})})}),(0,$.jsx)(Qn,{align:`end`,className:`w-fit min-w-20`,children:R(e,Wn)})]})]}),(0,$.jsx)(Di,{className:`w-fit min-w-20`,children:R(e,Oi)})]},e.name)})}),A.length>0&&(0,$.jsx)(vi,{label:se,children:A.map(e=>{let t=cs((h[e.name]??(f.isError&&!f.data?{status:`failed`,error:f.error.message}:void 0))?.status),i=a===e.name,c=br();return(0,$.jsxs)(ki,{open:S===e.name,onOpenChange:t=>C(t?e.name:null),children:[(0,$.jsxs)(Ei,{render:(0,$.jsx)(`div`,{className:q(`oc-settings-group-row group relative flex items-center transition-colors duration-150 select-none`,i?`bg-interactive-selection`:`hover:bg-interactive-hover`),onContextMenu:c?void 0:t=>{t.preventDefault(),C(e.name)}}),children:[(0,$.jsxs)(`button`,{onClick:()=>{o(e.name),s(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:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(ls,{tone:t,enabled:e.enabled}),(0,$.jsx)(`span`,{className:`typography-ui-label font-normal truncate text-foreground`,children:e.name}),(0,$.jsx)(`span`,{title:e.type===`local`?r(`settings.mcp.sidebar.serverType.localTitle`):r(`settings.mcp.sidebar.serverType.remoteTitle`),children:e.type===`local`?(0,$.jsx)(X,{name:`server`,className:`h-3 w-3 text-muted-foreground/60 flex-shrink-0`}):(0,$.jsx)(X,{name:`global`,className:`h-3 w-3 text-muted-foreground/60 flex-shrink-0`})})]}),(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground/60 truncate leading-tight pl-4`,children:e.type===`local`?e.command?.join(` `)??``:e.url??``})]}),(0,$.jsxs)(cr,{open:b===e.name,onOpenChange:t=>{t&&C(null),x(t?e.name:null)},children:[(0,$.jsx)(mr,{asChild:!0,children:(0,$.jsx)(J,{size:`xs`,variant:`ghost`,className:`flex-shrink-0 -mr-1 opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100`,children:(0,$.jsx)(X,{name:`more-2`,className:`h-3.5 w-3.5`})})}),(0,$.jsx)(Qn,{align:`end`,className:`w-fit min-w-20`,children:R(e,Wn)})]})]}),(0,$.jsx)(Di,{className:`w-fit min-w-20`,children:R(e,Oi)})]},e.name)})}),A.length===0&&(0,$.jsx)(vi,{label:se,cardClassName:`hidden`,children:(0,$.jsx)(`span`,{})})]})}),t[54]=d.data,t[55]=d.error,t[56]=d.isError,t[57]=p.length,t[58]=h,t[59]=n,t[60]=b,t[61]=O,t[62]=R,t[63]=S,t[64]=a,t[65]=s,t[66]=o,t[67]=f.data,t[68]=f.error,t[69]=f.isError,t[70]=r,t[71]=A,t[72]=se,t[73]=ue):ue=t[73];let de=g!==null,fe;t[74]===v?fe=t[75]:(fe=e=>{!e&&!v&&_(null)},t[74]=v,t[75]=fe);let pe;t[76]===r?pe=t[77]:(pe=r(`settings.mcp.sidebar.deleteDialog.title`),t[76]=r,t[77]=pe);let me;t[78]===pe?me=t[79]:(me=(0,$.jsx)(Xt,{children:pe}),t[78]=pe,t[79]=me);let he=g?.name||``,ge;t[80]!==r||t[81]!==he?(ge=r(`settings.mcp.sidebar.deleteDialog.descriptionPrefix`,{name:he}),t[80]=r,t[81]=he,t[82]=ge):ge=t[82];let _e;t[83]===Symbol.for(`react.memo_cache_sentinel`)?(_e=(0,$.jsx)(`code`,{className:`text-foreground`,children:`opencode.json`}),t[83]=_e):_e=t[83];let ve;t[84]===ge?ve=t[85]:(ve=(0,$.jsxs)(Zt,{children:[ge,` `,_e,`.`]}),t[84]=ge,t[85]=ve);let K;t[86]!==me||t[87]!==ve?(K=(0,$.jsxs)(qt,{children:[me,ve]}),t[86]=me,t[87]=ve,t[88]=K):K=t[88];let ye;t[89]===Symbol.for(`react.memo_cache_sentinel`)?(ye=()=>_(null),t[89]=ye):ye=t[89];let be;t[90]===r?be=t[91]:(be=r(`settings.common.actions.cancel`),t[90]=r,t[91]=be);let xe;t[92]!==v||t[93]!==be?(xe=(0,$.jsx)(J,{size:`sm`,variant:`ghost`,onClick:ye,disabled:v,children:be}),t[92]=v,t[93]=be,t[94]=xe):xe=t[94];let Se;t[95]!==v||t[96]!==r?(Se=r(v?`settings.mcp.sidebar.actions.deleting`:`settings.common.actions.delete`),t[95]=v,t[96]=r,t[97]=Se):Se=t[97];let Ce;t[98]!==I||t[99]!==v||t[100]!==Se?(Ce=(0,$.jsx)(J,{size:`sm`,onClick:I,disabled:v,children:Se}),t[98]=I,t[99]=v,t[100]=Se,t[101]=Ce):Ce=t[101];let we;t[102]!==xe||t[103]!==Ce?(we=(0,$.jsxs)(Jt,{children:[xe,Ce]}),t[102]=xe,t[103]=Ce,t[104]=we):we=t[104];let Te;t[105]!==K||t[106]!==we?(Te=(0,$.jsxs)(Yt,{className:`max-w-md`,children:[K,we]}),t[105]=K,t[106]=we,t[107]=Te):Te=t[107];let Ee;t[108]!==de||t[109]!==fe||t[110]!==Te?(Ee=(0,$.jsx)(Qt,{open:de,onOpenChange:fe,children:Te}),t[108]=de,t[109]=fe,t[110]=Te,t[111]=Ee):Ee=t[111];let De;return t[112]!==ue||t[113]!==Ee?(De=(0,$.jsxs)(`div`,{className:`oc-settings-page-content h-full overflow-y-auto bg-background p-3`,children:[ce,ue,Ee]}),t[112]=ue,t[113]=Ee,t[114]=De):De=t[114],De};function ds(e){return{selectedMcpName:e.selectedMcpName,setSelectedMcp:e.setSelectedMcp,setMcpDraft:e.setMcpDraft,deleteMcp:e.deleteMcp}}function fs(e){return e.scope===`project`}function ps(e){return e.scope!==`project`}function ms(e){return setTimeout(e,500)}function hs(e){Y.error(e instanceof Error?e.message:String(e))}function gs(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function _s(e){return Array.isArray(e)&&e.every(e=>typeof e==`string`)}function vs(e,t){return t===void 0?{ok:!1,error:e}:{ok:!1,error:e,parsed:t}}function ys(e,t,n){return{ok:!0,name:e,type:t,command:bs(n),url:typeof n.url==`string`?n.url.trim():``,environment:xs(n,`env`,`environment`),headers:xs(n,`headers`),oauthEnabled:Ss(n),oauthClientId:typeof n.oauth==`object`&&n.oauth!==null?String(n.oauth.clientId??``).trim():``,oauthClientSecret:typeof n.oauth==`object`&&n.oauth!==null?String(n.oauth.clientSecret??``).trim():``,oauthScope:typeof n.oauth==`object`&&n.oauth!==null?String(n.oauth.scope??``).trim():``,oauthRedirectUri:typeof n.oauth==`object`&&n.oauth!==null?String(n.oauth.redirectUri??``).trim():``,timeout:Cs(n),enabled:ws(n)}}function bs(e){let t=e.command,n=e.args;if(_s(t)&&_s(n))return[...t,...n];if(_s(t))return t;if(typeof t==`string`&&t.trim()){let e=t.trim().split(/\s+/);return _s(n)?[...e,...n]:e}return _s(n)?n:[]}function xs(e,...t){for(let n of t){let t=e[n];if(!gs(t))continue;let r=Object.entries(t).filter(([e,t])=>e&&typeof t==`string`);if(r.length>0)return r.map(([e,t])=>({key:e,value:String(t)}))}return[]}function Ss(e){if(e.oauth===!1||e.oauth===null||e.oauth===void 0||!gs(e.oauth))return!1;let t=e.oauth;return!!(typeof t.clientId==`string`&&t.clientId.trim()||typeof t.clientSecret==`string`&&t.clientSecret.trim()||typeof t.scope==`string`&&t.scope.trim()||typeof t.redirectUri==`string`&&t.redirectUri.trim())}function Cs(e){let t=e.timeout;if(typeof t==`number`&&Number.isFinite(t)&&t>0)return String(Math.floor(t));if(typeof t==`string`&&t.trim()){let e=Number(t);if(Number.isFinite(e)&&e>0)return String(Math.floor(e))}return``}function ws(e){return`disabled`in e&&e.disabled===!0?!1:`enabled`in e?!!e.enabled:!0}function Ts(e){let t=e.mcpServers;if(gs(t)){let e=Object.keys(t);if(e.length===1){let n=e[0],r=t[n];if(gs(r))return{name:n,entry:r}}if(e.length>1)return null}let n=Object.keys(e).filter(t=>{let n=e[t];return t!==`mcpServers`&&gs(n)});if(n.length===1){let t=n[0],r=e[t];if(Es(r))return{name:t,entry:r}}return null}function Es(e){return e.type===`local`||e.type===`remote`||Array.isArray(e.command)||typeof e.url==`string`||Array.isArray(e.args)}function Ds(e,t){let n;try{let t=e.trim();if(!t)return vs(`No JSON content provided`);n=JSON.parse(t)}catch(e){return vs(e instanceof Error?`Invalid JSON: ${e.message}`:`Invalid JSON`)}if(!gs(n))return vs(`Expected a JSON object, not an array or primitive`);let r=n,i=r.mcpServers;if(gs(i)){let e=Object.keys(i);if(e.length===0)return vs(`mcpServers object is empty`,n);if(e.length>1)return vs(`Paste one server at a time. Found `+e.length+` servers in mcpServers`,n);let t=e[0],r=i[t];return gs(r)?ys(t,Os(r),r):vs(`Server entry is not a valid object`,n)}let a=r.mcp;if(gs(a)){let e=Object.keys(a);if(e.length===0)return vs(`mcp object is empty`,n);if(e.length>1)return vs(`Paste one server at a time. Found `+e.length+` servers in mcp`,n);let t=e[0],r=a[t];return gs(r)?ys(t,Os(r),r):vs(`Server entry in mcp is not a valid object`,n)}let o=Ts(r);if(o)return ys(o.name,Os(o.entry),o.entry);if(Es(r)){let e=Os(r);return ys(typeof r.name==`string`&&r.name.trim()?r.name.trim():t?.fallbackName,e,r)}return vs(`No recognizable MCP server configuration found in JSON`,n)}function Os(e){return e.type===`remote`?`remote`:e.type===`local`?`local`:typeof e.url==`string`&&e.url.trim()?`remote`:(Array.isArray(e.command)||typeof e.command==`string`||Array.isArray(e.args),`local`)}function ks(e,t,n){let r=n?.isNewServer??!1,i=e.name,a=r&&i?i:t.name??``;return{...t,name:a,type:e.type,command:e.type===`local`?e.command:[],url:e.type===`remote`?e.url:``,environment:e.environment,headers:e.type===`remote`?e.headers:[],oauthEnabled:e.type===`remote`&&e.oauthEnabled,oauthClientId:e.type===`remote`?e.oauthClientId:``,oauthClientSecret:e.type===`remote`?e.oauthClientSecret:``,oauthScope:e.type===`remote`?e.oauthScope:``,oauthRedirectUri:e.type===`remote`?e.oauthRedirectUri:``,timeout:e.type===`remote`?e.timeout:``,enabled:e.enabled}}function As(e){let t=[],n=``,r=!1,i=!1;for(let a=0;a<e.length;a++){let o=e[a];if(o===`'`&&!i){r=!r;continue}if(o===`"`&&!r){i=!i;continue}if((o===` `||o===` `)&&!r&&!i){n&&=(t.push(n),``);continue}n+=o}return n&&t.push(n),t}function js(e){let t=e.trim();if(!t)return{code:null,context:null,stateKey:null};try{let e=new URL(t),n=e.searchParams.get(`code`);if(typeof n==`string`&&n.trim())return{code:n.trim(),context:Br(e.searchParams),stateKey:Ur(e.searchParams)}}catch{}return{code:t,context:null,stateKey:null}}var Ms=({value:e,onChange:t,pasteCommandTitle:n,pasteCommandLabel:r,pasteSuccess:i,clipboardReadFailed:a,preview:o})=>{let[s,c]=Q.useState(()=>e.join(`
|
|
3
|
+
`)),l=Q.useRef(e);Q.useEffect(()=>{JSON.stringify(l.current)!==JSON.stringify(e)&&(l.current=e,c(e.join(`
|
|
4
|
+
`)))},[e]);let u=e=>{t(e.split(`
|
|
5
|
+
`).filter(e=>e.trim().length>0))};return(0,$.jsxs)(`div`,{className:`space-y-2`,"data-bwignore":`true`,"data-1p-ignore":`true`,"data-lpignore":`true`,children:[(0,$.jsx)(`div`,{className:`flex items-center justify-end gap-2`,children:(0,$.jsxs)(J,{variant:`ghost`,size:`xs`,className:`!font-normal gap-1 text-muted-foreground`,onClick:async()=>{try{let e=(await navigator.clipboard.readText()).trim(),n=e.includes(`
|
|
6
|
+
`)?e.split(`
|
|
7
|
+
`).filter(e=>e.trim()):As(e);c(n.join(`
|
|
8
|
+
`)),t(n),Y.success(i(n.length))}catch{Y.error(a)}},type:`button`,title:n,children:[(0,$.jsx)(X,{name:`clipboard`,className:`h-3 w-3`}),r]})}),(0,$.jsx)(Cr,{embedded:!0,value:s,onChange:e=>{c(e.target.value),u(e.target.value)},onBlur:()=>{let e=s.split(`
|
|
9
|
+
`).map(e=>e.trimEnd()).join(`
|
|
10
|
+
`);c(e),u(e)},placeholder:`npx
|
|
11
|
+
-y
|
|
12
|
+
@modelcontextprotocol/server-postgres
|
|
13
|
+
postgresql://user:pass@host/db`,rows:Math.max(4,e.length+1),className:`font-mono typography-meta resize-y min-h-[80px]`,spellCheck:!1}),e.length>0&&(0,$.jsxs)(`details`,{className:`group`,children:[(0,$.jsx)(`summary`,{className:`typography-micro text-muted-foreground/60 cursor-pointer select-none hover:text-muted-foreground`,children:o(e.length)}),(0,$.jsx)(`div`,{className:`mt-1 rounded-md bg-[var(--surface-elevated)] px-3 py-2 overflow-x-auto`,children:(0,$.jsx)(`code`,{className:`typography-micro text-foreground/80 whitespace-pre`,children:e.map((e,t)=>(0,$.jsxs)(`span`,{className:`block`,children:[(0,$.jsxs)(`span`,{className:`text-muted-foreground select-none mr-2`,children:[`[`,t,`]`]}),e]},t))})})]})]})},Ns=e=>e.toUpperCase().replace(/[^A-Z0-9_]/g,`_`),Ps=({value:e,onChange:t,keyTransform:n=Ns,keyPlaceholder:r=`API_KEY`,keyInputClassName:i=`w-36 shrink-0 font-mono typography-meta uppercase`,pasteLabel:a=`Paste .env`,pasteTitle:o=`Paste KEY=VALUE lines from clipboard`,noPairsFoundError:s,importSuccess:c,clipboardReadFailed:l,keyLabel:u,valueLabel:d,valuePlaceholder:f,hideValueTitle:p,showValueTitle:m,addVariable:h,plainTextWarning:g,removeVariableAria:_})=>{let[v,y]=Q.useState(new Set),b=()=>t([...e,{key:``,value:``}]),x=n=>{t(e.filter((e,t)=>t!==n)),y(e=>{let t=new Set(e);return t.delete(n),t})},S=(n,r,i)=>{let a=[...e];a[n]={...a[n],[r]:i},t(a)},C=e=>{y(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},w=async()=>{try{let n=await navigator.clipboard.readText(),r=[];for(let e of n.split(`
|
|
14
|
+
`)){let t=e.trim();if(!t||t.startsWith(`#`))continue;let n=t.indexOf(`=`);if(n===-1)continue;let i=t.slice(0,n).trim(),a=t.slice(n+1).trim();(a.startsWith(`"`)&&a.endsWith(`"`)||a.startsWith(`'`)&&a.endsWith(`'`))&&(a=a.slice(1,-1)),i&&r.push({key:i,value:a})}if(r.length===0){Y.error(s);return}let i=[...e];for(let e of r){let t=i.findIndex(t=>t.key===e.key);t===-1?i.push(e):i[t]=e}t(i),Y.success(c(r.length))}catch{Y.error(l)}},T=e.some(e=>e.value.length>0);return(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground w-32 shrink-0`,children:u}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:d})]}),(0,$.jsxs)(J,{variant:`ghost`,size:`xs`,className:`!font-normal gap-1 text-muted-foreground`,onClick:w,type:`button`,title:o,children:[(0,$.jsx)(X,{name:`clipboard`,className:`h-3 w-3`}),a]})]}),(0,$.jsx)(`div`,{className:`space-y-1.5`,children:e.map((e,t)=>(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(fn,{value:e.key,onChange:e=>S(t,`key`,n(e.target.value)),placeholder:r,className:i,"data-bwignore":`true`,"data-1p-ignore":`true`,"data-lpignore":`true`,spellCheck:!1}),(0,$.jsxs)(`div`,{className:`relative flex-1 flex items-center`,children:[(0,$.jsx)(fn,{type:v.has(t)?`text`:`password`,value:e.value,onChange:e=>S(t,`value`,e.target.value),placeholder:f,className:`font-mono typography-meta pr-8 w-full`,autoComplete:`new-password`,"data-bwignore":`true`,"data-1p-ignore":`true`,"data-lpignore":`true`,spellCheck:!1}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>C(t),className:`absolute right-2 text-muted-foreground/60 hover:text-muted-foreground`,title:v.has(t)?p:m,children:v.has(t)?(0,$.jsx)(X,{name:`eye-off`,className:`h-3.5 w-3.5`}):(0,$.jsx)(X,{name:`eye`,className:`h-3.5 w-3.5`})})]}),(0,$.jsx)(J,{size:`sm`,variant:`ghost`,className:`h-7 w-7 px-0 shrink-0 text-muted-foreground hover:text-[var(--status-error)]`,onClick:()=>x(t),"aria-label":_,children:(0,$.jsx)(X,{name:`delete-bin`,className:`h-3.5 w-3.5`})})]},t))}),(0,$.jsxs)(J,{variant:`outline`,size:`xs`,className:`!font-normal gap-1.5`,onClick:b,type:`button`,children:[(0,$.jsx)(X,{name:`add`,className:`h-3.5 w-3.5`}),h]}),T&&(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground/60`,children:g})]})},Fs=e=>{let t=(0,Ii.c)(14),{status:n,enabled:r,getStatusLabel:i,variant:a}=e,o=a===void 0?`compact`:a;if(!r||!n)return null;let s,c;if(t[0]!==i||t[1]!==n||t[2]!==o){c=Symbol.for(`react.early_return_sentinel`);bb0:{let e={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`){let r=q(`typography-micro font-medium rounded-full px-2 py-0.5`,e.text,e.bg),a;t[5]!==i||t[6]!==n?(a=i(n),t[5]=i,t[6]=n,t[7]=a):a=t[7],c=(0,$.jsxs)(`span`,{className:r,children:[`● `,a]});break bb0}s=q(`typography-micro font-medium`,e.text)}t[0]=i,t[1]=n,t[2]=o,t[3]=s,t[4]=c}else s=t[3],c=t[4];if(c!==Symbol.for(`react.early_return_sentinel`))return c;let l;t[8]!==i||t[9]!==n?(l=i(n),t[8]=i,t[9]=n,t[10]=l):l=t[10];let u;return t[11]!==s||t[12]!==l?(u=(0,$.jsxs)(`span`,{className:s,children:[`● `,l]}),t[11]=s,t[12]=l,t[13]=u):u=t[13],u},Is=(e,t,n)=>{switch(e){case`connected`:return t(`settings.mcp.page.status.description.connected`);case`failed`:return n?.trim()||t(`settings.mcp.page.status.description.failedDefault`);case`needs_auth`:return t(`settings.mcp.page.status.description.needsAuth`);case`needs_client_registration`:return n?.trim()||t(`settings.mcp.page.status.description.needsClientRegistrationDefault`);case`disabled`:return t(`settings.mcp.page.status.description.disabled`);default:return t(`settings.mcp.page.status.description.default`)}},Ls=e=>{switch(e){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)]`}},Rs=(e,t,n,r)=>!!(e===`failed`||e===`needs_auth`||e===`needs_client_registration`||t||n||r),zs=(e,t)=>{if(typeof window>`u`)return null;let n=new URL(Lr,c()||window.location.origin);return typeof e==`string`&&e.trim()&&n.searchParams.set(`server`,e.trim()),typeof t==`string`&&t.trim()&&n.searchParams.set(`directory`,t.trim()),n.toString()},Bs=async e=>{let t=await l(`/api/mcp/auth/pending`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({state:e.state,name:e.name,directory:typeof e.directory==`string`&&e.directory.trim()?e.directory.trim():null})});if(!t.ok){let e=await t.json().catch(()=>null);throw Error(e?.error||`Failed to prepare MCP authorization callback`)}},Vs=async e=>{let t=await l(`/api/mcp/auth/pending?state=${encodeURIComponent(e)}`);if(!t.ok)return null;let n=await t.json().catch(()=>null);return n?.name?.trim()?{name:n.name.trim(),directory:typeof n.directory==`string`&&n.directory.trim()?n.directory.trim():null}:null},Hs=async e=>{typeof e!=`string`||!e.trim()||await l(`/api/mcp/auth/pending?state=${encodeURIComponent(e.trim())}`,{method:`DELETE`}).catch(()=>void 0)},Us=(e,t,n)=>{let r=e instanceof Error?e.message:t;return/oauth state required/i.test(r)?n(`settings.mcp.page.toast.authSessionExpired`):r},Ws=(e,t,n)=>{let r=typeof t==`string`&&t.trim()?t.trim():`__global__`;return`${n}::${e??`__none__`}::${r}`},Gs=()=>{let{t:e}=Me(),t=Q.useCallback((t,n)=>e(t,n),[e]),{selectedMcpName:n,mcpDraft:r,setMcpDraft:a,setSelectedMcp:o,createMcp:s,updateMcp:c,deleteMcp:l}=la(le(e=>({selectedMcpName:e.selectedMcpName,mcpDraft:e.mcpDraft,setMcpDraft:e.setMcpDraft,setSelectedMcp:e.setSelectedMcp,createMcp:e.createMcp,updateMcp:e.updateMcp,deleteMcp:e.deleteMcp}))),u=Ti(),d=i(),f=bi(u),p=Si(u),m=f.data??[],h=p.data??{},g=Q.useMemo(()=>k(),[]),_=pi(e=>e.getDiagnosticForDirectory(u)),v=pi(e=>e.connect),y=pi(e=>e.disconnect),b=pi(e=>e.startAuth),x=pi(e=>e.completeAuth),S=pi(e=>e.clearAuth),C=pi(e=>e.testConnection),T=n?m.find(e=>e.name===n)??null:null,E=!!(r&&r.name===n&&!T),[D,O]=Q.useState(``),[A,j]=Q.useState(`user`),[M,N]=Q.useState(`local`),[P,F]=Q.useState([]),[I,L]=Q.useState(``),[R,z]=Q.useState([]),[B,V]=Q.useState([]),[H,U]=Q.useState(!0),[W,ee]=Q.useState(``),[G,te]=Q.useState(``),[ne,re]=Q.useState(``),[ie,ae]=Q.useState(``),[oe,se]=Q.useState(``),[ce,ue]=Q.useState(!0),[de,fe]=Q.useState(!1),[pe,me]=Q.useState(!1),[he,ge]=Q.useState(!1),[_e,ve]=Q.useState(!1),[K,ye]=Q.useState(!1),[be,xe]=Q.useState(!1),[Se,Ce]=Q.useState(!1),[we,Te]=Q.useState(!1),[Ee,De]=Q.useState(null),[Oe,ke]=Q.useState(null),[Ae,Ne]=Q.useState(``),[Pe,Fe]=Q.useState(!1),Ie=Q.useRef(0),Le=Q.useRef(!1),[Re,ze]=Q.useState(!1),[Be,Ve]=Q.useState(!1),[He,Ue]=Q.useState(``),[We,Ge]=Q.useState(null),Ke=Q.useMemo(()=>Ws(n,u,d),[u,n,d]),qe=Q.useRef(Ke),Je=Q.useRef(null),Ye=Q.useCallback(()=>{De(null),ke(null),Ne(``),Fe(!1),Ie.current=0,Te(!1),ye(!1),xe(!1),Le.current=!1},[]),Xe=Q.useCallback(()=>{Ue(``),Ge(null),Ve(!0)},[]),Ze=Q.useCallback(async()=>{try{let e=await navigator.clipboard.readText();Ue(e),Ge(null)}catch{Y.error(e(`settings.mcp.page.toast.clipboardReadFailed`))}},[e]),Qe=Q.useCallback(()=>{let t=Ds(He,{fallbackName:D});if(!t.ok){Ge(t.error);return}let n=ks(t,{name:D,scope:A,type:M,command:P,url:I,environment:R,headers:B,oauthEnabled:H,oauthClientId:W,oauthClientSecret:G,oauthScope:ne,oauthRedirectUri:ie,timeout:oe,enabled:ce},{isNewServer:E});O(n.name),N(n.type),F(n.command??[]),L(n.url??``),z(n.environment??[]),V(n.headers??[]),U(n.oauthEnabled??!1),ee(n.oauthClientId??``),te(n.oauthClientSecret??``),re(n.oauthScope??``),ae(n.oauthRedirectUri??``),se(n.timeout??``),ue(n.enabled??!0),Ve(!1),Ue(``),Ge(null),Y.success(e(`settings.mcp.page.toast.configImported`))},[He,D,A,M,P,I,R,B,H,W,G,ne,ie,oe,ce,E,e]);Q.useEffect(()=>{if(E&&r){O(r.name),j(r.scope||`user`),N(r.type),F(r.command),L(r.url),z(r.environment),V(r.headers),U(r.oauthEnabled),ee(r.oauthClientId),te(r.oauthClientSecret),re(r.oauthScope),ae(r.oauthRedirectUri),se(r.timeout),ue(r.enabled),ze(!1),Je.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(T){j(T.scope===`project`?`project`:`user`);let e=oa(T.environment),t=T.type===`remote`?T:null,n=oa(t?.headers),r=t?.oauth,i=r&&typeof r==`object`?r:null,a=r!==!1,o=T.type,s=o===`local`?T.command??[]:[],c=o===`remote`?T.url??``:``,l=typeof t?.timeout==`number`&&Number.isFinite(t.timeout)?String(t.timeout):``;N(o),F(s),L(c),z(e),V(n),U(a),ee(a?i?.clientId??``:``),te(a?i?.clientSecret??``:``),re(a?i?.scope??``:``),ae(a?i?.redirectUri??``:``),se(l),ue(T.enabled),ze(!1),Je.current={mcpType:o,command:s,url:c,envEntries:e,headerEntries:n,oauthEnabled:a,oauthClientId:a?i?.clientId??``:``,oauthClientSecret:a?i?.clientSecret??``:``,oauthScope:a?i?.scope??``:``,oauthRedirectUri:a?i?.redirectUri??``:``,timeout:l,enabled:T.enabled}}},[T,E,r]);let $e=Q.useMemo(()=>{let e=Je.current;return e?M!==e.mcpType||ce!==e.enabled||JSON.stringify(P)!==JSON.stringify(e.command)||I!==e.url||JSON.stringify(R)!==JSON.stringify(e.envEntries)||JSON.stringify(B)!==JSON.stringify(e.headerEntries)||H!==e.oauthEnabled||W!==e.oauthClientId||G!==e.oauthClientSecret||ne!==e.oauthScope||ie!==e.oauthRedirectUri||oe!==e.timeout:!1},[M,P,I,R,B,H,W,G,ne,ie,oe,ce]),et=async()=>{let t=E?D.trim():n??``;if(!t){Y.error(e(`settings.mcp.page.toast.nameRequired`));return}if(E&&m.some(e=>e.name===t)){Y.error(e(`settings.mcp.page.toast.serverNameExists`));return}if(M===`local`&&P.filter(Boolean).length===0){Y.error(e(`settings.mcp.page.toast.localCommandRequired`));return}if(M===`remote`&&!I.trim()){Y.error(e(`settings.mcp.page.toast.remoteUrlRequired`));return}let r={name:t,scope:A,type:M,command:P,url:I,environment:R,headers:B,oauthEnabled:H,oauthClientId:W,oauthClientSecret:G,oauthScope:ne,oauthRedirectUri:ie,timeout:oe,enabled:ce};fe(!0);try{let n={directory:Ti(),transportIdentity:i()},l=E?await s(r,n):await c(t,r,n);l.ok?(await Hs(Oe),Ye(),E&&(a(null),o(t)),l.reloadFailed?Y.warning(l.message||e(E?`settings.mcp.page.toast.serverCreatedReloadFailed`:`settings.mcp.page.toast.savedReloadFailed`),{description:l.warning||e(`settings.mcp.page.toast.retryRefreshHint`)}):Y.success(l.message||e(E?`settings.mcp.page.toast.serverCreatedReloading`:`settings.mcp.page.toast.savedReloading`))):Y.error(e(`settings.mcp.page.toast.saveFailed`))}catch(t){Y.error(t instanceof Error?t.message:e(`settings.mcp.page.toast.unexpectedError`))}finally{fe(!1)}},tt=async()=>{if(!n)return;ge(!0);let t=await l(n,{directory:Ti(),transportIdentity:i()});t.ok?(await Hs(Oe),Ye(),t.reloadFailed?Y.warning(t.message||e(`settings.mcp.page.toast.serverDeletedReloadFailed`,{name:n}),{description:t.warning||e(`settings.mcp.page.toast.refreshListIfStale`)}):Y.success(t.message||e(`settings.mcp.page.toast.serverDeleted`,{name:n})),me(!1)):Y.error(e(`settings.mcp.page.toast.deleteFailed`)),ge(!1)},nt=async()=>{if(n){ve(!0);try{if(h[n]?.status===`connected`)await y(n,u),Y.success(e(`settings.mcp.page.toast.disconnected`));else{await v(n,u);let t=xi(w,u)[n];t?.status===`connected`?Y.success(e(`settings.mcp.page.toast.connected`)):t?.status===`needs_auth`?Y.message(e(`settings.mcp.page.toast.connectionNeedsAuthorization`)):t?.status===`needs_client_registration`?Y.message(e(`settings.mcp.page.toast.connectionNeedsClientRegistration`)):t?.status===`failed`?Y.error(t.error||e(`settings.mcp.page.toast.connectionFailed`)):Y.message(e(`settings.mcp.page.toast.connectionAttemptFinished`));return}}catch(t){Y.error(t instanceof Error?t.message:e(`settings.mcp.page.toast.connectionFailed`))}finally{ve(!1)}}},rt=Q.useCallback(()=>E?(Y.error(e(`settings.mcp.page.toast.createServerBeforeLiveActions`)),!1):!$e||(Y.error(e(`settings.mcp.page.toast.saveBeforeLiveActions`)),!1),[$e,E,e]);Q.useEffect(()=>{qe.current=Ke,ve(!1),Ce(!1),Ye()},[Ye,Ke]);let it=Q.useCallback(async()=>{if(!n||M!==`remote`||!rt())return;ye(!0);let r=Ke,i=null;try{let t=xi(w,u)[n]?.status;Le.current=t===`needs_auth`||t===`needs_client_registration`;let a=zs(n,u);if(!a)throw Error(e(`settings.mcp.page.toast.oauthRedirectUrlBuildFailed`));if(!ie.trim()&&!g){let t=await c(n,{oauthEnabled:H,oauthClientId:W,oauthClientSecret:G,oauthScope:ne,oauthRedirectUri:a});if(!t.ok)throw Error(e(`settings.mcp.page.toast.oauthBrowserCallbackSaveFailed`));if(t.reloadFailed)throw Error(t.warning||t.message||e(`settings.mcp.page.toast.openCodeReloadFailedAfterCallbackSave`));if(qe.current!==r)return;ae(a),Je.current=Je.current?{...Je.current,oauthRedirectUri:a}:Je.current}let o=await b(n,u),s=Ur(new URL(o).searchParams);if(s&&(i=s,await Bs({state:s,name:n,directory:u})),qe.current!==r)return;De(o),ke(s??null),Fe(!0),Ie.current=0;let l=await kr(o);if(qe.current!==r)return;l?Y.message(e(g?`settings.mcp.page.toast.completeAuthorizationInBrowserWithPaste`:`settings.mcp.page.toast.completeAuthorizationInBrowser`)):Y.error(e(`settings.mcp.page.toast.openAuthorizationUrlFailed`))}catch(n){await Hs(i),qe.current===r&&Y.error(Us(n,e(`settings.mcp.page.toast.authorizationStartFailed`),t))}finally{qe.current===r&&ye(!1)}},[g,u,M,W,G,H,ie,ne,rt,Ke,n,b,e,t,c]),at=Q.useCallback(async()=>{if(!n||!rt())return;xe(!0);let r=Ke;try{if(await S(n,u),qe.current!==r)return;De(null),ke(null),Ne(``),Fe(!1),Ie.current=0,await Hs(Oe),Y.success(e(`settings.mcp.page.toast.savedAuthorizationRemoved`))}catch(n){qe.current===r&&Y.error(Us(n,e(`settings.mcp.page.toast.clearAuthorizationFailed`),t))}finally{qe.current===r&&xe(!1)}},[Oe,S,u,rt,Ke,n,e,t]),ot=Q.useCallback(async()=>{if(Ee){if((await je(Ee)).ok){Y.success(e(`settings.mcp.page.toast.authorizationUrlCopied`));return}Y.error(e(`settings.mcp.page.toast.authorizationUrlCopyFailed`))}},[Ee,e]),st=Q.useCallback(async()=>{let r=js(Ae);if(!r.code){Y.error(e(`settings.mcp.page.toast.pasteCallbackOrCodeFirst`));return}let i=r.stateKey?await Vs(r.stateKey):null,a=r.context??i,o=a?.name??n,s=a?.directory??u;if(!o){Y.error(e(`settings.mcp.page.toast.missingServerDetails`));return}if(!a&&!rt())return;Te(!0);let c=Ke;try{if(await x(o,r.code,s),await Hs(r.stateKey??Oe),qe.current!==c)return;Ne(``),De(null),ke(null),Fe(!1),Ie.current=0,Y.success(o===n?e(`settings.mcp.page.toast.authorizationCompleted`):e(`settings.mcp.page.toast.authorizationCompletedFor`,{name:o}))}catch(n){qe.current===c&&Y.error(Us(n,e(`settings.mcp.page.toast.authorizationCompleteFailed`),t))}finally{qe.current===c&&Te(!1)}},[Ae,Oe,x,u,rt,Ke,n,e,t]),ct=Q.useCallback(async()=>{if(!(!n||!rt())){if(!ce){Y.error(e(`settings.mcp.page.toast.enableServerBeforeTest`));return}Ce(!0);try{let t=await C(n,u),r=t.status?.status;t.warning?Y.warning(t.warning):r===`connected`?Y.success(e(`settings.mcp.page.toast.connectionTestSucceeded`)):r===`needs_auth`?Y.message(e(`settings.mcp.page.toast.connectionNeedsAuthorization`)):r===`needs_client_registration`?Y.message(e(`settings.mcp.page.toast.connectionNeedsClientRegistration`)):r===`failed`?Y.error(t.status?.error||t.error||e(`settings.mcp.page.toast.connectionTestFailed`)):t.error?Y.error(t.error):Y.message(e(`settings.mcp.page.toast.connectionTestFinished`))}catch(t){Y.error(t instanceof Error?t.message:e(`settings.mcp.page.toast.connectionTestFailed`))}finally{Ce(!1)}}},[ce,u,rt,n,e,C]);if(Q.useEffect(()=>{if(!Pe||!n)return;let t=!1,r=null,i=()=>{Fe(!1),Ie.current=0,Le.current=!1},a=async()=>{try{let o=await Ci(w,u,d);if(t)return;Ie.current+=1;let s=o[n];if(s?.status===`connected`){i(),De(null),Ne(``),Y.success(e(`settings.mcp.page.toast.authorizationCompleted`));return}if(s?.status===`failed`){i(),Y.error(s.error||e(`settings.mcp.page.toast.authorizationFailed`));return}if(s&&Le.current&&s.status!==`needs_auth`&&s.status!==`needs_client_registration`){i(),De(null),Ne(``);return}if(Ie.current>=30){i(),Y.message(e(`settings.mcp.page.toast.authorizationStillInProgress`));return}r=window.setTimeout(()=>void a(),2e3)}catch{if(t)return;if(Ie.current+=1,Ie.current>=30){i(),Y.message(e(`settings.mcp.page.toast.authorizationStillInProgress`));return}r=window.setTimeout(()=>void a(),2e3)}};return r=window.setTimeout(()=>void a(),2e3),()=>{t=!0,r!==null&&window.clearTimeout(r)}},[Pe,u,n,e,d]),f.isError&&!f.data)return(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center px-6`,children:(0,$.jsx)(`p`,{className:`typography-meta text-[var(--status-error)] text-center`,children:f.error.message})});if(!n)return(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,$.jsxs)(`div`,{className:`text-center text-muted-foreground`,children:[(0,$.jsx)(X,{name:`plug`,className:`mx-auto mb-3 h-12 w-12 opacity-50`}),(0,$.jsx)(`p`,{className:`typography-body`,children:e(`settings.mcp.page.empty.selectServer`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 opacity-75`,children:e(`settings.mcp.page.empty.addNewOne`)})]})});let lt=h[n],ut=n?_[n]:void 0,dt=lt??ut??(p.isError&&!p.data?{status:`failed`,error:p.error.message}:void 0),ft=lt?.status===`connected`,pt=lt?.status===`needs_auth`||lt?.status===`needs_client_registration`,mt=g?null:zs(n,u),ht=Is(dt?.status,t,dt&&`error`in dt?dt.error:void 0),gt=t=>{switch(t){case`connected`:return e(`settings.mcp.page.status.label.connected`);case`failed`:return e(`settings.mcp.page.status.label.failed`);case`needs_auth`:return e(`settings.mcp.page.status.label.needsAuth`);case`needs_client_registration`:return e(`settings.mcp.page.status.label.needsRegistration`);default:return t}};return(0,$.jsxs)(Sr,{outerClassName:`h-full`,className:`w-full`,children:[(0,$.jsxs)(`div`,{className:`oc-settings-page-content mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8`,children:[(0,$.jsx)(`div`,{children:(0,$.jsxs)(`div`,{className:`min-w-0`,children:[E?(0,$.jsx)(`h2`,{className:`typography-ui-header font-semibold text-foreground truncate`,children:e(`settings.mcp.page.header.newServer`)}):(0,$.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,$.jsx)(`h2`,{className:`typography-ui-header font-semibold text-foreground truncate`,children:n}),(0,$.jsx)(Fs,{status:dt?.status,enabled:ce,getStatusLabel:gt,variant:`pill`})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 mt-0.5`,children:[(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground truncate`,children:E?e(`settings.mcp.page.header.configureNewServer`):e(`settings.mcp.page.header.transport`,{type:e(M===`local`?`settings.mcp.page.transport.local`:`settings.mcp.page.transport.remote`)})}),!E&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(J,{variant:ft?`outline`:`default`,size:`xs`,className:`!font-normal`,onClick:nt,disabled:_e||!ce,children:e(_e?`settings.mcp.page.actions.working`:ft?`settings.mcp.page.actions.disconnect`:`settings.mcp.page.actions.connect`)}),M===`remote`&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(J,{variant:pt?`default`:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>void it(),disabled:K||!ce,children:e(K?`settings.mcp.page.actions.starting`:pt?`settings.mcp.page.actions.authorize`:`settings.mcp.page.actions.reauthorize`)}),(0,$.jsx)(J,{variant:`ghost`,size:`xs`,className:`!font-normal gap-1 text-muted-foreground`,onClick:()=>void at(),disabled:be||!ce,children:e(be?`settings.mcp.page.actions.clearing`:`settings.mcp.page.actions.clearAuth`)})]}),ft&&(0,$.jsx)(J,{variant:`ghost`,size:`xs`,className:`!font-normal gap-1 text-muted-foreground`,onClick:()=>void ct(),disabled:Se||!ce,children:e(Se?`settings.mcp.page.actions.testing`:`settings.mcp.page.actions.test`)})]})]})]})}),!E&&Rs(dt?.status,Ee,pt,Pe)&&(0,$.jsx)(`div`,{className:`px-2`,children:(0,$.jsxs)(`div`,{className:q(`rounded-lg border p-3`,Ls(dt?.status)),children:[(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e(`settings.mcp.page.status.runtimeStatus`)}),(0,$.jsx)(Fs,{status:dt?.status,enabled:ce,getStatusLabel:gt})]}),(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:ht}),(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground/80`,children:A===`project`?e(`settings.mcp.page.status.projectScopedTo`,{directory:u??e(`settings.mcp.page.status.activeProject`)}):e(`settings.mcp.page.status.userScoped`)})]}),(0,$.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:!ft&&(0,$.jsx)(J,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>void ct(),disabled:Se||!ce,children:e(Se?`settings.mcp.page.actions.testing`:`settings.mcp.page.actions.testConnection`)})}),Ee&&(0,$.jsx)(`div`,{className:`rounded-md border border-[var(--interactive-border)] bg-[var(--surface-background)] px-3 py-2`,children:(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground`,children:e(`settings.mcp.page.auth.authorizationUrl`)}),(0,$.jsx)(`div`,{className:`break-all typography-micro text-foreground font-mono`,children:Ee}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsxs)(J,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>void kr(Ee),children:[(0,$.jsx)(X,{name:`external-link`,className:`h-3.5 w-3.5`}),e(`settings.mcp.page.actions.openInBrowser`)]}),(0,$.jsxs)(J,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>void ot(),children:[(0,$.jsx)(X,{name:`clipboard`,className:`h-3.5 w-3.5`}),e(`settings.mcp.page.actions.copyLink`)]})]})]})}),M===`remote`&&(pt||Pe||Ee)&&(0,$.jsx)(`div`,{className:`rounded-md border border-[var(--interactive-border)] bg-[var(--surface-background)] px-3 py-3`,children:(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:e(`settings.mcp.page.auth.manualFallbackTitle`)}),(0,$.jsx)(`p`,{className:`mt-1 typography-micro text-muted-foreground`,children:e(`settings.mcp.page.auth.manualFallbackDescription`)})]}),(0,$.jsx)(Cr,{embedded:!0,value:Ae,onChange:e=>Ne(e.target.value),placeholder:e(`settings.mcp.page.auth.callbackInputPlaceholder`),rows:3,className:`font-mono typography-meta resize-y`,"data-bwignore":`true`,"data-1p-ignore":`true`,spellCheck:!1}),(0,$.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:(0,$.jsx)(J,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>void st(),disabled:we,children:e(we?`settings.mcp.page.actions.completing`:`settings.mcp.page.actions.completeAuthorization`)})})]})})]}),Pe&&(0,$.jsx)(`p`,{className:`mt-4 typography-micro text-muted-foreground`,children:e(`settings.mcp.page.auth.waitingForOpenCode`)})]})}),(0,$.jsx)(`div`,{"data-settings-item":`mcp.server`,children:(0,$.jsx)(vi,{label:e(`settings.mcp.page.server.title`),cardClassName:`p-3`,children:(0,$.jsxs)(`div`,{className:`space-y-3`,children:[E&&(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center sm:gap-8`,children:[(0,$.jsx)(`div`,{className:`flex min-w-0 flex-col sm:w-56 shrink-0`,children:(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e(`settings.mcp.page.server.name`)})}),(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2 sm:w-fit sm:flex-initial`,children:[(0,$.jsx)(fn,{value:D,onChange:e=>O(e.target.value.toLowerCase().replace(/[^a-z0-9_-]/g,`-`)),placeholder:e(`settings.mcp.page.server.namePlaceholder`),className:`h-7 w-48 font-mono px-2`,autoFocus:!0}),(0,$.jsxs)(ln,{value:A,onValueChange:e=>j(e),children:[(0,$.jsx)(rn,{className:`!h-7 !w-7 !min-w-0 !px-0 !py-0 justify-center [&>svg:last-child]:hidden`,title:e(A===`user`?`settings.common.scope.global`:`settings.common.scope.project`),children:A===`user`?(0,$.jsx)(X,{name:`user-3`,className:`h-3.5 w-3.5`}):(0,$.jsx)(X,{name:`folder`,className:`h-3.5 w-3.5`})}),(0,$.jsxs)(an,{align:`end`,children:[(0,$.jsx)(tn,{value:`user`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(X,{name:`user-3`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:e(`settings.common.scope.global`)})]})}),(0,$.jsx)(tn,{value:`project`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(X,{name:`folder`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:e(`settings.common.scope.project`)})]})})]})]})]})]}),E&&(0,$.jsx)(`div`,{children:(0,$.jsxs)(J,{variant:`outline`,size:`xs`,className:`!font-normal gap-1.5`,onClick:Xe,type:`button`,title:e(`settings.mcp.page.server.importJsonTitle`),children:[(0,$.jsx)(X,{name:`file-code`,className:`h-3.5 w-3.5`}),e(`settings.mcp.page.server.importJson`)]})}),(0,$.jsxs)(`div`,{className:`group flex cursor-pointer items-center gap-2`,role:`button`,tabIndex:0,"aria-pressed":ce,onClick:()=>ue(!ce),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),ue(!ce))},children:[(0,$.jsx)(sn,{checked:ce,onChange:ue,ariaLabel:e(`settings.mcp.page.server.enableAria`)}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e(`settings.mcp.page.server.enable`)})]}),(0,$.jsx)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center sm:gap-8`,children:(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-col sm:w-56 shrink-0`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e(`settings.mcp.page.server.transportMode`)}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[(0,$.jsx)(J,{variant:`chip`,size:`xs`,"aria-pressed":M===`local`,onClick:()=>N(`local`),className:`!font-normal`,children:e(`settings.mcp.page.transport.local`)}),(0,$.jsx)(J,{variant:`chip`,size:`xs`,"aria-pressed":M===`remote`,onClick:()=>N(`remote`),className:`!font-normal`,children:e(`settings.mcp.page.transport.remote`)})]})]})})]})})}),(0,$.jsx)(`div`,{"data-settings-item":`mcp.command`,children:M===`local`?(0,$.jsx)(vi,{label:e(`settings.mcp.page.connection.command`),cardClassName:`p-3`,children:(0,$.jsx)(Ms,{value:P,onChange:F,pasteCommandTitle:e(`settings.mcp.page.connection.pasteCommandTitle`),pasteCommandLabel:e(`settings.mcp.page.connection.pasteCommand`),pasteSuccess:t=>e(`settings.mcp.page.toast.pastedArgumentsCount`,{count:t}),clipboardReadFailed:e(`settings.mcp.page.toast.clipboardReadFailed`),preview:t=>e(`settings.mcp.page.connection.previewArgs`,{count:t})})}):(0,$.jsx)(vi,{children:(0,$.jsx)(Nr,{label:e(`settings.mcp.page.connection.serverUrl`),children:(0,$.jsx)(fn,{value:I,onChange:e=>L(e.target.value),placeholder:e(`settings.mcp.page.connection.serverUrlPlaceholder`),className:`font-mono typography-meta`})})})}),M===`remote`&&(0,$.jsx)(`div`,{"data-settings-item":`mcp.advanced`,children:(0,$.jsx)(vi,{label:e(`settings.mcp.page.advanced.title`),cardClassName:`p-3`,children:(0,$.jsxs)(Mi,{open:Re,onOpenChange:ze,children:[(0,$.jsxs)(ji,{className:`flex w-full items-center justify-between py-0.5 group`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 text-left`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label font-normal text-foreground`,children:e(`settings.mcp.page.advanced.configure`)}),(0,$.jsxs)(`span`,{className:`typography-micro text-muted-foreground`,children:[`(`,e(H?`settings.mcp.page.advanced.autoDetect`:`settings.mcp.page.advanced.custom`),` · `,B.length,` `,e(`settings.mcp.page.advanced.headers`),oe?` · ${oe}ms`:``,`)`]})]}),Re?(0,$.jsx)(X,{name:`arrow-down-s`,className:`h-4 w-4 text-muted-foreground group-hover:text-foreground transition-colors`}):(0,$.jsx)(X,{name:`arrow-right-s`,className:`h-4 w-4 text-muted-foreground group-hover:text-foreground transition-colors`})]}),(0,$.jsx)(Ai,{className:`pt-2`,children:(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(Nr,{label:e(`settings.mcp.page.advanced.timeoutMs`),description:e(`settings.mcp.page.advanced.timeoutHint`),children:(0,$.jsx)(fn,{type:`number`,min:`1`,step:`1`,value:oe,onChange:e=>se(e.target.value),placeholder:`5000`,className:`w-32 font-mono`,"data-bwignore":`true`,"data-1p-ignore":`true`})}),(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`mb-2 typography-ui-label text-foreground`,children:[e(`settings.mcp.page.advanced.requestHeaders`),B.length>0&&(0,$.jsxs)(`span`,{className:`ml-1.5 typography-micro text-muted-foreground font-normal`,children:[`(`,B.length,`)`]})]}),(0,$.jsx)(Ps,{value:B,onChange:V,keyTransform:e=>e.trimStart(),keyPlaceholder:e(`settings.mcp.page.advanced.headerNamePlaceholder`),keyInputClassName:`w-36 shrink-0 font-mono typography-meta`,pasteLabel:e(`settings.mcp.page.advanced.pasteHeaders`),pasteTitle:e(`settings.mcp.page.advanced.pasteHeadersTitle`),noPairsFoundError:e(`settings.mcp.page.toast.noKeyValuePairsFound`),importSuccess:t=>e(`settings.mcp.page.toast.importedVariablesCount`,{count:t}),clipboardReadFailed:e(`settings.mcp.page.toast.clipboardReadFailed`),keyLabel:e(`settings.mcp.page.env.key`),valueLabel:e(`settings.mcp.page.env.value`),valuePlaceholder:e(`settings.mcp.page.env.valuePlaceholder`),hideValueTitle:e(`settings.mcp.page.env.hide`),showValueTitle:e(`settings.mcp.page.env.show`),addVariable:e(`settings.mcp.page.env.addVariable`),plainTextWarning:e(`settings.mcp.page.env.plainTextWarning`),removeVariableAria:e(`settings.mcp.page.env.removeVariableAria`)})]}),(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`group flex cursor-pointer items-center gap-2 py-1.5`,role:`button`,tabIndex:0,"aria-pressed":H,onClick:()=>U(!H),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),U(!H))},children:[(0,$.jsx)(sn,{checked:H,onChange:U,ariaLabel:e(`settings.mcp.page.advanced.oauthAutoDetectionAria`)}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e(`settings.mcp.page.advanced.oauthAutoDetection`)})]}),(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,$.jsx)(fn,{value:W,onChange:e=>ee(e.target.value),placeholder:e(`settings.mcp.page.advanced.oauthClientIdPlaceholder`),className:`font-mono typography-meta`,disabled:!H,"data-bwignore":`true`,"data-1p-ignore":`true`}),(0,$.jsx)(fn,{value:G,onChange:e=>te(e.target.value),placeholder:e(`settings.mcp.page.advanced.oauthClientSecretPlaceholder`),className:`font-mono typography-meta`,disabled:!H,"data-bwignore":`true`,"data-1p-ignore":`true`}),(0,$.jsx)(fn,{value:ne,onChange:e=>re(e.target.value),placeholder:e(`settings.mcp.page.advanced.oauthScopesPlaceholder`),className:`font-mono typography-meta`,disabled:!H,"data-bwignore":`true`,"data-1p-ignore":`true`}),(0,$.jsx)(fn,{value:ie,onChange:e=>ae(e.target.value),placeholder:e(`settings.mcp.page.advanced.oauthRedirectUriPlaceholder`),className:`font-mono typography-meta`,disabled:!H,"data-bwignore":`true`,"data-1p-ignore":`true`})]}),(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground`,children:e(`settings.mcp.page.advanced.oauthHint`)}),mt&&(0,$.jsxs)(`p`,{className:`typography-micro text-muted-foreground`,children:[e(`settings.mcp.page.advanced.oauthCallbackHint`),(0,$.jsx)(`span`,{className:`mt-1 block break-all font-mono text-foreground/80`,children:mt})]})]})]})})]})})}),(0,$.jsx)(`div`,{"data-settings-item":`mcp.environment`,children:(0,$.jsx)(vi,{label:(0,$.jsxs)(`span`,{children:[e(`settings.mcp.page.env.title`),R.length>0&&(0,$.jsxs)(`span`,{className:`ml-1.5 typography-micro text-muted-foreground font-normal`,children:[`(`,R.length,`)`]})]}),cardClassName:`p-3`,children:R.length===0?(0,$.jsxs)(J,{variant:`outline`,size:`xs`,className:`!font-normal gap-1.5`,onClick:()=>z([{key:``,value:``}]),children:[(0,$.jsx)(X,{name:`add`,className:`h-3.5 w-3.5`}),e(`settings.mcp.page.env.addEnvironmentVariable`)]}):(0,$.jsx)(Ps,{value:R,onChange:z,keyPlaceholder:e(`settings.mcp.page.env.keyPlaceholder`),pasteLabel:e(`settings.mcp.page.env.pasteEnv`),pasteTitle:e(`settings.mcp.page.env.pasteEnvTitle`),noPairsFoundError:e(`settings.mcp.page.toast.noKeyValuePairsFound`),importSuccess:t=>e(`settings.mcp.page.toast.importedVariablesCount`,{count:t}),clipboardReadFailed:e(`settings.mcp.page.toast.clipboardReadFailed`),keyLabel:e(`settings.mcp.page.env.key`),valueLabel:e(`settings.mcp.page.env.value`),valuePlaceholder:e(`settings.mcp.page.env.valuePlaceholder`),hideValueTitle:e(`settings.mcp.page.env.hide`),showValueTitle:e(`settings.mcp.page.env.show`),addVariable:e(`settings.mcp.page.env.addVariable`),plainTextWarning:e(`settings.mcp.page.env.plainTextWarning`),removeVariableAria:e(`settings.mcp.page.env.removeVariableAria`)})})}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(J,{onClick:et,disabled:de||!$e&&!E,size:`xs`,className:`!font-normal`,children:e(de?`settings.common.actions.saving`:E?`settings.common.actions.create`:`settings.common.actions.saveChanges`)}),!E&&(0,$.jsx)(J,{variant:`destructive`,size:`xs`,className:`!font-normal`,onClick:()=>me(!0),children:e(`settings.common.actions.delete`)})]})]}),(0,$.jsx)(Qt,{open:Be,onOpenChange:e=>{e||(Ve(!1),Ue(``),Ge(null))},children:(0,$.jsxs)(Yt,{className:`max-w-md`,children:[(0,$.jsxs)(qt,{children:[(0,$.jsx)(Xt,{children:e(`settings.mcp.page.importDialog.title`)}),(0,$.jsx)(Zt,{children:e(`settings.mcp.page.importDialog.description`)})]}),(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(Cr,{value:He,onChange:e=>{Ue(e.target.value),Ge(null)},placeholder:`{
|
|
15
|
+
"mcpServers": {
|
|
16
|
+
"postgres": {
|
|
17
|
+
"command": "npx",
|
|
18
|
+
"args": ["-y", "@modelcontextprotocol/server-postgres"]
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}`,rows:8,className:`font-mono typography-meta resize-y`,spellCheck:!1,"data-bwignore":`true`,"data-1p-ignore":`true`}),We&&(0,$.jsx)(`p`,{className:`typography-micro text-[var(--status-error)]`,children:We}),(0,$.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:(0,$.jsxs)(J,{variant:`outline`,size:`xs`,className:`!font-normal gap-1`,onClick:Ze,type:`button`,children:[(0,$.jsx)(X,{name:`clipboard`,className:`h-3.5 w-3.5`}),e(`settings.mcp.page.importDialog.pasteFromClipboard`)]})})]}),(0,$.jsxs)(Jt,{children:[(0,$.jsx)(J,{variant:`outline`,onClick:()=>{Ve(!1),Ue(``),Ge(null)},className:`text-foreground`,children:e(`settings.common.actions.cancel`)}),(0,$.jsx)(J,{onClick:Qe,disabled:!He.trim(),size:`sm`,children:e(`settings.common.actions.import`)})]})]})}),(0,$.jsx)(Qt,{open:pe,onOpenChange:e=>{!e&&!he&&me(!1)},children:(0,$.jsxs)(Yt,{className:`max-w-md`,children:[(0,$.jsxs)(qt,{children:[(0,$.jsx)(Xt,{children:e(`settings.mcp.page.deleteDialog.title`,{name:n??``})}),(0,$.jsxs)(Zt,{children:[e(`settings.mcp.page.deleteDialog.descriptionPrefix`),` `,(0,$.jsx)(`code`,{className:`text-foreground`,children:`opencode.json`}),`.`,` `,e(`settings.mcp.page.deleteDialog.descriptionSuffix`)]})]}),(0,$.jsxs)(Jt,{children:[(0,$.jsx)(J,{variant:`outline`,onClick:()=>me(!1),disabled:he,className:`text-foreground`,children:e(`settings.common.actions.cancel`)}),(0,$.jsx)(J,{variant:`destructive`,size:`sm`,onClick:tt,disabled:he,children:e(he?`settings.mcp.page.actions.deleting`:`settings.common.actions.delete`)})]})]})})]})},Ks=Q.memo(function(e){let t=(0,Ii.c)(24),{checked:n,onChange:r,disabled:i,ariaLabel:a,className:o,iconClassName:s}=e,c=i!==void 0&&i,l;t[0]!==n||t[1]!==c||t[2]!==r?(l=e=>{e.preventDefault(),e.stopPropagation(),!c&&!n&&r()},t[0]=n,t[1]=c,t[2]=r,t[3]=l):l=t[3];let u=l,d;t[4]!==n||t[5]!==c||t[6]!==r?(d=e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),!c&&!n&&r())},t[4]=n,t[5]=c,t[6]=r,t[7]=d):d=t[7];let f=d,p=n?`bg-[color-mix(in_srgb,var(--primary-base)_80%,transparent)] shadow-none hover:bg-[var(--primary-base)]`:`bg-[var(--surface-muted)] shadow-[inset_0_0_0_1px_var(--interactive-border)] hover:bg-[var(--interactive-hover)]`,m;t[8]!==o||t[9]!==p?(m=q(`group/radio relative flex h-[14px] w-[14px] min-h-[14px] min-w-[14px] shrink-0 self-center items-center justify-center rounded-full outline-none`,`transition-[background-color,box-shadow] duration-200 ease-out`,p,`focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] focus-visible:ring-offset-1 focus-visible:ring-offset-background`,`disabled:cursor-not-allowed disabled:opacity-50`,o),t[8]=o,t[9]=p,t[10]=m):m=t[10];let h=!n&&`opacity-0`,g;t[11]!==s||t[12]!==h?(g=q(`block h-[5px] w-[5px] rounded-full bg-white`,h,s),t[11]=s,t[12]=h,t[13]=g):g=t[13];let _;t[14]===g?_=t[15]:(_=(0,$.jsx)(`span`,{"aria-hidden":!0,className:g}),t[14]=g,t[15]=_);let v;return t[16]!==a||t[17]!==n||t[18]!==c||t[19]!==u||t[20]!==f||t[21]!==m||t[22]!==_?(v=(0,$.jsx)(`button`,{type:`button`,role:`radio`,onClick:u,onKeyDown:f,disabled:c,"aria-checked":n,"aria-label":a,className:m,children:_}),t[16]=a,t[17]=n,t[18]=c,t[19]=u,t[20]=f,t[21]=m,t[22]=_,t[23]=v):v=t[23],v}),qs=e=>{let t=e?.trim();return t?{location:{directory:t}}:void 0},Js=()=>{let e=pe.getSdkClient().plugin;if(!e?.list||!e.check||!e.update)throw Error(`OpenCode plugin status is not available`);return e},Ys=e=>{switch(e.type){case`package`:return{kind:`package`,target:e.target,version:e.version??null,outdated:e.outdated===!0,updating:e.updating===!0};case`local`:return{kind:`local`,path:e.path};case`builtin`:case`sdk`:return{kind:`builtin`};default:throw Error(`Unexpected plugin source: ${JSON.stringify(e)}`)}},Xs=e=>{if(e.status===`active`)return{kind:`active`};if(e.status===`failed`)return{kind:`failed`,error:e.error,ref:e.ref??null};throw Error(`Unexpected plugin state: ${JSON.stringify(e)}`)},Zs=e=>({source:Ys(e.source),state:Xs(e.state)}),Qs=e=>{if(!Array.isArray(e))throw Error(`OpenCode plugin status payload is invalid`);return e.map(e=>Zs(e))};async function $s(e,t){return Qs((await Js().list(qs(e),t?{signal:t}:void 0))?.data)}async function ec(e,t){return Qs((await Js().check(qs(e),t?{signal:t}:void 0))?.data)}async function tc(e,t,n){let r=t.trim();if(!r)throw Error(`plugin.update requires a target`);await Js().update({...qs(e),targets:[r]},n?{signal:n}:void 0)}function nc(e){return e instanceof Error&&e.message.trim()?e.message:typeof e==`string`&&e.trim()?e:`plugin operation failed`}var rc=1500,ic=e=>e?.trim()||null,ac=(e,t=i())=>E.plugins.list(e,t),oc=(e,t,n=!1,r=i())=>E.plugins.registry(e,t,n,r),sc=(e,t=i())=>E.plugins.runtime(e,t),cc=0,lc=()=>(cc+=1,cc),uc=()=>{cc+=1},dc=(e,t,n)=>e.getQueryData(sc(t,n)),fc=(e=zt(),t=i())=>{let n=ic(e);return{queryKey:ac(n,t),queryFn:async({signal:e})=>{let t=await l(wc(`/api/config/plugins`,n),{headers:Dc(n),signal:e});if(!t.ok)throw Error(`Failed to load plugins`);let r=await t.json();return{entries:r.entries??[],files:r.files??[]}},staleTime:5e3,retry:2}},pc=(e,t,n=!1,r=i())=>{let a=ic(e),o=F(t);return{queryKey:oc(a,o,n,r),queryFn:async({signal:e})=>{let t={};for(let r of Ec(o)){let i=await l(Tc(r,n,a),{headers:Dc(a),signal:e});if(!i.ok)throw Error(`Failed to load plugin registry info`);let o=await i.json();for(let e of o.results??[])t[e.spec]=e}return t},staleTime:n?0:3e5,retry:2}},mc=(e=zt(),t=i())=>{let n=ic(e);return{queryKey:sc(n,t),queryFn:async({signal:e})=>{let r=lc(),i=await $s(n,e);if(r!==cc){let e=dc(w,n,t);if(e)return e;throw Error(`Stale plugin runtime read`)}return i},staleTime:5e3,retry:!1}},hc=(e,t,n=i())=>JSON.stringify([n,ic(e)??``,t]),gc=e=>{let t=(0,Ii.c)(7),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let r=n,i=Ct(Oc),a;t[2]===i?a=t[3]:(a=fc(ic(i)??ic(pe.getDirectory())),t[2]=i,t[3]=a);let o;return t[4]!==r.enabled||t[5]!==a?(o={...a,enabled:r.enabled},t[4]=r.enabled,t[5]=a,t[6]=o):o=t[6],Ee(o)},_c=(e,t)=>{let n=(0,Ii.c)(6),r=t!==void 0&&t,i=Ct(kc),a;n[0]!==i||n[1]!==r||n[2]!==e?(a=pc(ic(i)??ic(pe.getDirectory()),e,r),n[0]=i,n[1]=r,n[2]=e,n[3]=a):a=n[3];let o;return n[4]===a?o=n[5]:(o={...a},n[4]=a,n[5]=o),Ee(o)},vc=()=>{let e=(0,Ii.c)(2),t=Ct(Ac),n;return e[0]===t?n=e[1]:(n=ic(t)??ic(pe.getDirectory()),e[0]=t,e[1]=n),n},yc=e=>{let t=(0,Ii.c)(7),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let r=n,i=vc(),a;t[2]===i?a=t[3]:(a=mc(i),t[2]=i,t[3]=a);let o;return t[4]!==r.enabled||t[5]!==a?(o={...a,enabled:r.enabled},t[4]=r.enabled,t[5]=a,t[6]=o):o=t[6],Ee(o)},bc=async(e,t,n)=>{let r=ic(t);return i()===n?e.fetchQuery({...fc(r,n),staleTime:0}):e.getQueryData(ac(r,n))??{entries:[],files:[]}},xc=async(e=w,t,n)=>{let r=ic(t),a=i(),o=await pc(r,n,!0,a).queryFn({signal:new AbortController().signal});return e.setQueryData(oc(r,n,!1,a),o),o},Sc=async(e,t,n)=>{let r=ic(t);if(i()!==n)return dc(e,r,n);let a=lc(),o=await $s(r);return a!==cc||i()!==n?dc(e,r,n):(e.setQueryData(sc(r,n),o),o)},Cc=async(e=zt(),t=w)=>{let n=ic(e),r=i(),a=await ec(n);return uc(),i()===r&&t.setQueryData(sc(n,r),a),a};function wc(e,t){return`${e}${t?`?directory=${encodeURIComponent(t)}`:``}`}function Tc(e,t,n){let r=new URLSearchParams;t&&r.set(`refresh`,`true`),n&&r.set(`directory`,n);let i=r.toString();return`/api/config/plugins/registry?${`specs=${e.map(encodeURIComponent).join(`,`)}`}${i?`&${i}`:``}`}function Ec(e){let t=[],n=[],r=0;for(let i of e){let e=encodeURIComponent(i),a=n.length===0?e.length:r+1+e.length;if(n.length>0&&a>rc){t.push(n),n=[i],r=e.length;continue}n.push(i),r=a}return n.length>0&&t.push(n),t}function Dc(e){return e?{"x-opencode-directory":e}:void 0}function Oc(e){return e.getActiveProject?.()?.path??null}function kc(e){return e.getActiveProject?.()?.path??null}function Ac(e){return e.getActiveProject?.()?.path??null}var jc=()=>{try{let e=Ct.getState().getActiveProject?.();if(e?.path?.trim())return e.path.trim();let t=pe.getDirectory();if(t?.trim())return t.trim()}catch(e){console.warn(`[PluginsStore] Error resolving config directory:`,e)}return null},Mc=5e3,Nc=`__default__`,Pc=new Map,Fc=new Map,Ic=1500,Lc=e=>e?.trim()||Nc,Rc=e=>{Pc.delete(Lc(e))},zc=oe()(ce(se((e,t)=>({entries:[],files:[],selectedId:null,isLoading:!1,registryInfo:{},isLoadingRegistry:!1,draft:null,packageUpdates:{},setSelected:t=>e({selectedId:t}),setDraft:t=>e({draft:t}),loadPlugins:async n=>{let r=jc(),a=i(),s=o(),c=()=>a===i()&&s===o()&&r===jc(),l=Lc(r),u=Date.now(),d=Pc.get(l)??0,f=t().entries.length>0||t().files.length>0;if(!n?.force&&f&&u-d<Mc)return!0;let p=Fc.get(l);if(!n?.force&&p)return p;let m=(async()=>{e({isLoading:!0});try{let i=n?.force?await bc(w,r,a):await w.fetchQuery(fc(r,a));return c()?(e({entries:i.entries??[],files:i.files??[],isLoading:!1}),Pc.set(l,Date.now()),n?.force||t().loadRegistryInfo(),!0):!1}catch(t){return console.error(`[PluginsStore] Failed to load plugins:`,t),c()&&e({isLoading:!1}),!1}})();Fc.set(l,m);try{return await m}finally{Fc.delete(l)}},loadRegistryInfo:async n=>{let r=Hc(n?.specs??t().entries.map(e=>e.spec));if(r.length===0){e({isLoadingRegistry:!1});return}e({isLoadingRegistry:!0});try{let i=jc(),a={...t().registryInfo};for(let e of Uc(r)){let t=await l(Vc(e,n?.force===!0,i),{headers:Wc(i)});if(!t.ok)throw Error(`Failed to load plugin registry info`);let r=await Jc(t);for(let e of r.results??[])a[e.spec]=e}e({registryInfo:a,isLoadingRegistry:!1})}catch(t){console.error(`[PluginsStore] Failed to load plugin registry info:`,t),e({isLoadingRegistry:!1})}},updateToLatest:async e=>{let n=t().entries.find(t=>t.id===e);if(!n)return{ok:!1};let r=t().registryInfo[n.spec];return!r||r.kind!==`npm-ok`||!r.hasUpdate||!r.latestVersion?{ok:!1}:await t().updateEntry(e,{spec:`${r.name}@${r.latestVersion}`})},updatePackage:async n=>{let r=jc(),a=i(),o=hc(r,n,a);if(t().packageUpdates[o]?.kind===`running`)return!1;e({packageUpdates:{...t().packageUpdates,[o]:{kind:`running`}}});try{if(await tc(r,n),i()===a)try{await Sc(w,r,a)}catch(e){console.error(`[PluginsStore] Plugin updated, but status could not be reread:`,e)}let s={...t().packageUpdates};return delete s[o],e({packageUpdates:s}),!0}catch(n){return console.error(`[PluginsStore] Failed to update plugin package:`,n),e({packageUpdates:{...t().packageUpdates,[o]:{kind:`failed`,error:nc(n)}}}),!1}},createEntry:async e=>{let n=await qc(async t=>await l(Bc(`/api/config/plugins/entry`,t),{method:`POST`,headers:Gc(t),body:JSON.stringify(Kc(e))}));return n.ok&&t().loadRegistryInfo({specs:[e.spec],force:!0}),n},updateEntry:async(e,n)=>{let r=t().entries.find(t=>t.id===e)?.spec,i=n.spec??r,a=await qc(async t=>await l(Bc(`/api/config/plugins/entry/${encodeURIComponent(e)}`,t),{method:`PATCH`,headers:Gc(t),body:JSON.stringify(Kc(n))}));return a.ok&&i&&t().loadRegistryInfo({specs:[i],force:!0}),a},deleteEntry:async n=>{let r=t().entries.find(e=>e.id===n),i=await qc(async e=>await l(Bc(`/api/config/plugins/entry/${encodeURIComponent(n)}`,e),{method:`DELETE`,headers:Wc(e)}));if(i.ok&&t().selectedId===n&&e({selectedId:null}),i.ok&&r){let n={...t().registryInfo};delete n[r.spec],e({registryInfo:n})}return i},readFile:async e=>{try{let t=jc(),n=await l(Bc(`/api/config/plugins/file/${encodeURIComponent(e)}`,t),{headers:Wc(t)});if(!n.ok)throw Error(`Failed to read plugin file`);return await Jc(n)}catch(e){return console.error(`[PluginsStore] Failed to read plugin file:`,e),null}},createFile:async e=>qc(async t=>await l(Bc(`/api/config/plugins/file`,t),{method:`POST`,headers:Gc(t),body:JSON.stringify(e)})),updateFile:async(e,t)=>qc(async n=>await l(Bc(`/api/config/plugins/file/${encodeURIComponent(e)}`,n),{method:`PUT`,headers:Gc(n),body:JSON.stringify(t)})),deleteFile:async n=>{let r=await qc(async e=>await l(Bc(`/api/config/plugins/file/${encodeURIComponent(n)}`,e),{method:`DELETE`,headers:Wc(e)}));return r.ok&&t().selectedId===n&&e({selectedId:null}),r},getById:e=>t().entries.find(t=>t.id===e)??t().files.find(t=>t.id===e)}),{name:`plugins-store`,storage:ge(),partialize:e=>({selectedId:e.selectedId})}),{name:`plugins-store`}));function Bc(e,t){return`${e}${t?`?directory=${encodeURIComponent(t)}`:``}`}function Vc(e,t,n){let r=new URLSearchParams;t&&r.set(`refresh`,`true`),n&&r.set(`directory`,n);let i=r.toString();return`/api/config/plugins/registry?${`specs=${e.map(encodeURIComponent).join(`,`)}`}${i?`&${i}`:``}`}function Hc(e){return Array.from(new Set(e.map(e=>e.trim()).filter(Boolean)))}function Uc(e){let t=[],n=[],r=0;for(let i of e){let e=encodeURIComponent(i),a=n.length===0?e.length:r+1+e.length;n.length>0&&a>Ic?(t.push(n),n=[i],r=e.length):(n.push(i),r=a)}return n.length>0&&t.push(n),t}function Wc(e){return e?{"x-opencode-directory":e}:void 0}function Gc(e){return{"Content-Type":`application/json`,...e?{"x-opencode-directory":e}:{}}}function Kc(e){let t={};return e.spec!==void 0&&(t.spec=e.spec),e.options!==void 0&&(t.options=e.options),e.scope!==void 0&&(t.scope=e.scope),t}async function qc(e){let t=i(),n=o();try{let r=jc(),a=await e(r),s=await Jc(a).catch(()=>null);if(!a.ok)throw Error(s?.error||`Failed to update plugin configuration`);if(t!==i()||n!==o())return{ok:!0};Rc(r);let c=await bc(w,r,t);return r===jc()&&t===i()&&n===o()&&(zc.setState({entries:c.entries,files:c.files}),Pc.set(Lc(r),Date.now())),{ok:!0,reloadFailed:s?.reloadFailed===!0,message:s?.message,warning:s?.warning}}catch(e){return console.error(`[PluginsStore] Failed to update plugin configuration:`,e),{ok:!1}}}async function Jc(e){return await e.json()}var Yc=/^[a-z0-9][a-z0-9-_.]*\.(js|ts|mjs|cjs)$/;function Xc(e){let t=e.trim();if(t===``)return{ok:!0,value:void 0};try{let e=JSON.parse(t);return typeof e!=`object`||!e||Array.isArray(e)?{ok:!1}:{ok:!0,value:e}}catch{return{ok:!1}}}var Zc=({open:e,onOpenChange:t,defaultScope:n=`user`})=>{let{t:r}=Me(),i=zc(e=>e.createEntry),a=zc(e=>e.createFile),[o,s]=Q.useState(`npm`),[c,l]=Q.useState(``),[u,d]=Q.useState(``),[f,p]=Q.useState(``),[m,h]=Q.useState(``),[g,_]=Q.useState(n),[v,y]=Q.useState(!1),b=Q.useCallback(()=>{l(``),d(``),p(``),h(``),_(n)},[n]);Q.useEffect(()=>{e&&(s(`npm`),b())},[e,b]);let x=e=>{e!==o&&(s(e),b())},S=Q.useMemo(()=>Xc(u),[u]),C=!S.ok,w=o===`file`&&f.trim()!==``&&!Yc.test(f.trim()),T=(o===`npm`||o===`path`)&&c.trim()===``,E=o===`file`&&m.trim()===``,D=o===`file`&&f.trim()===``,O=v||C||o===`npm`&&T||o===`path`&&T||o===`file`&&(D||w||E),k=async()=>{if(!O){y(!0);try{let e;e=o===`file`?await a({fileName:f.trim(),content:m,scope:g}):await i({spec:c.trim(),options:S.ok?S.value:void 0,scope:g}),e.ok?(Y.success(e.message||r(`settings.plugins.toast.created`)),e.reloadFailed&&Y.warning(r(`settings.plugins.toast.reloadFailed`)),t(!1)):Y.error(e.message||r(`settings.plugins.sidebar.toast.deleteFailed`))}finally{y(!1)}}},A=Q.useMemo(()=>[{id:`npm`,label:r(`settings.plugins.dialog.add.tab.npm`)},{id:`path`,label:r(`settings.plugins.dialog.add.tab.path`)},{id:`file`,label:r(`settings.plugins.dialog.add.tab.file`)}],[r]);return(0,$.jsx)(Qt,{open:e,onOpenChange:e=>{!e&&v||t(e)},children:(0,$.jsxs)(Yt,{className:`max-w-xl`,children:[(0,$.jsxs)(qt,{children:[(0,$.jsx)(Xt,{children:r(`settings.plugins.dialog.add.title`)}),(0,$.jsx)(Zt,{children:r(`settings.plugins.sidebar.empty.description`)})]}),(0,$.jsx)(jr,{items:A,activeId:o,onSelect:e=>x(e),layoutMode:`fit`,variant:`active-pill`,activePillLowercase:!1,className:`h-10`}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(o===`npm`||o===`path`)&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{"data-settings-item":`plugins.spec`,className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`label`,{htmlFor:`plugin-spec`,className:`typography-ui-label text-foreground`,children:r(`settings.plugins.page.field.spec`)}),(0,$.jsx)(fn,{id:`plugin-spec`,value:c,onChange:e=>l(e.target.value),placeholder:r(`settings.plugins.page.field.spec.placeholder`),"aria-invalid":!T&&void 0,disabled:v}),T&&(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:r(`settings.plugins.validation.specRequired`)})]}),(0,$.jsxs)(`div`,{"data-settings-item":`plugins.options`,className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`label`,{htmlFor:`plugin-options`,className:`typography-ui-label text-foreground`,children:r(`settings.plugins.page.field.options`)}),(0,$.jsx)(Cr,{id:`plugin-options`,value:u,onChange:e=>d(e.target.value),rows:5,className:`font-mono`,hasError:C,disabled:v}),C&&(0,$.jsx)(`p`,{className:`typography-meta text-[var(--status-error)]`,children:r(`settings.plugins.page.field.options.invalidJson`)})]})]}),o===`file`&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{"data-settings-item":`plugins.content`,className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`label`,{htmlFor:`plugin-filename`,className:`typography-ui-label text-foreground`,children:r(`settings.plugins.page.field.fileName`)}),(0,$.jsx)(fn,{id:`plugin-filename`,value:f,onChange:e=>p(e.target.value),placeholder:`my-plugin.ts`,"aria-invalid":w||void 0,disabled:v}),w&&(0,$.jsx)(`p`,{className:`typography-meta text-[var(--status-error)]`,children:r(`settings.plugins.validation.fileName`)})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`label`,{htmlFor:`plugin-content`,className:`typography-ui-label text-foreground`,children:r(`settings.plugins.page.field.content`)}),(0,$.jsx)(Cr,{id:`plugin-content`,value:m,onChange:e=>h(e.target.value),rows:16,className:`font-mono`,disabled:v})]})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:r(`settings.plugins.page.field.scope`)}),(0,$.jsx)(`div`,{className:`flex items-center gap-4`,children:[`user`,`project`].map(e=>{let t=g===e,n=r(e===`user`?`settings.plugins.scope.user`:`settings.plugins.scope.project`);return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>_(e),disabled:v,className:`flex items-center gap-2 py-1 text-left disabled:opacity-50`,children:[(0,$.jsx)(Ks,{checked:t,onChange:()=>_(e),ariaLabel:n}),(0,$.jsx)(`span`,{className:q(`typography-ui-label font-normal`,t?`text-foreground`:`text-foreground/60`),children:n})]},e)})})]})]}),(0,$.jsxs)(Jt,{children:[(0,$.jsx)(J,{size:`sm`,variant:`ghost`,onClick:()=>t(!1),disabled:v,children:r(`settings.plugins.dialog.add.action.cancel`)}),(0,$.jsxs)(J,{size:`sm`,onClick:()=>{k()},disabled:O,children:[v?(0,$.jsx)(X,{name:`loader-4`,className:`h-3.5 w-3.5 animate-spin`}):null,r(`settings.plugins.dialog.add.action.submit`)]})]})]})})},Qc=e=>{let t=(0,Ii.c)(31),{info:n}=e,{t:r}=Me();if(!n)return null;let i=$c;switch(n.kind){case`npm-ok`:{if(!n.hasUpdate||!n.latestVersion)return null;let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(X,{name:`arrow-up-s`,className:`h-3 w-3`}),t[0]=e):e=t[0];let a;t[1]===n.latestVersion?a=t[2]:(a=(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 text-[var(--status-success)]`,children:[e,n.latestVersion]}),t[1]=n.latestVersion,t[2]=a);let o;return t[3]!==n.currentVersion||t[4]!==n.latestVersion||t[5]!==r||t[6]!==a?(o=i(a,r(`settings.plugins.registry.badge.update.tooltip`,{current:n.currentVersion??``,latest:n.latestVersion})),t[3]=n.currentVersion,t[4]=n.latestVersion,t[5]=r,t[6]=a,t[7]=o):o=t[7],o}case`npm-missing-version`:{let e;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(X,{name:`error-warning`,className:`h-3 w-3 text-[var(--status-warning)]`}),t[8]=e):e=t[8];let a;return t[9]!==n.currentVersion||t[10]!==n.name||t[11]!==r?(a=i(e,r(`settings.plugins.registry.badge.missingVersion.tooltip`,{version:n.currentVersion,name:n.name})),t[9]=n.currentVersion,t[10]=n.name,t[11]=r,t[12]=a):a=t[12],a}case`npm-missing-package`:{let e;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(X,{name:`error-warning`,className:`h-3 w-3 text-[var(--status-error)]`}),t[13]=e):e=t[13];let a;return t[14]!==n.name||t[15]!==r?(a=i(e,r(`settings.plugins.registry.badge.missingPackage.tooltip`,{name:n.name})),t[14]=n.name,t[15]=r,t[16]=a):a=t[16],a}case`npm-malformed`:{let e;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(X,{name:`error-warning`,className:`h-3 w-3 text-[var(--status-error)]`}),t[17]=e):e=t[17];let n;return t[18]===r?n=t[19]:(n=i(e,r(`settings.plugins.registry.badge.malformed.tooltip`)),t[18]=r,t[19]=n),n}case`npm-network`:{let e;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(X,{name:`cloud-off`,className:`h-3 w-3 text-muted-foreground`}),t[20]=e):e=t[20];let n;return t[21]===r?n=t[22]:(n=i(e,r(`settings.plugins.registry.badge.network.tooltip`)),t[21]=r,t[22]=n),n}case`path-missing`:{let e;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(X,{name:`error-warning`,className:`h-3 w-3 text-[var(--status-error)]`}),t[23]=e):e=t[23];let a;return t[24]!==n.absolutePath||t[25]!==r?(a=i(e,r(`settings.plugins.registry.badge.pathMissing.tooltip`,{path:n.absolutePath})),t[24]=n.absolutePath,t[25]=r,t[26]=a):a=t[26],a}case`path-unreadable`:{let e;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(X,{name:`error-warning`,className:`h-3 w-3 text-[var(--status-warning)]`}),t[27]=e):e=t[27];let a;return t[28]!==n.absolutePath||t[29]!==r?(a=i(e,r(`settings.plugins.registry.badge.pathUnreadable.tooltip`,{path:n.absolutePath})),t[28]=n.absolutePath,t[29]=r,t[30]=a):a=t[30],a}case`path-ok`:return null;default:return null}};function $c(e,t){return(0,$.jsxs)(hn,{children:[(0,$.jsx)(pn,{asChild:!0,children:(0,$.jsx)(`span`,{className:`inline-flex shrink-0 items-center gap-0.5 text-xs`,children:e})}),(0,$.jsx)(mn,{children:t})]})}var el=e=>e.startsWith(`/`)||/^[A-Za-z]:[\\/]/.test(e),tl=e=>{let t=e.replace(/\\/g,`/`),n=[],[r,...i]=t.split(`/`);for(let e of i)if(e!==``&&e!==`.`){if(e===`..`){n.pop();continue}n.push(e)}return`${/^[A-Za-z]:$/.test(r)?`${r.toUpperCase()}/`:`/`}${n.join(`/`)}`},nl=e=>tl(`${e.replace(/\\/g,`/`)}/..`),rl=e=>{try{let t=decodeURIComponent(new URL(e).pathname);return/^\/[A-Za-z]:\//.test(t)?t.slice(1):t}catch{return null}};function il(e,t){if(e.startsWith(`file://`)){let t=rl(e);return t?{kind:`local`,path:tl(t)}:null}return e.startsWith(`./`)||e.startsWith(`../`)?t?{kind:`local`,path:tl(`${nl(t)}/${e}`)}:null:el(e)?{kind:`local`,path:tl(e)}:{kind:`package`,target:e}}function al(e){return e?{kind:`local`,path:tl(e)}:null}var ol=(e,t)=>{if(e.kind===`package`)return t.source.kind===`package`&&t.source.target===e.target;if(t.source.kind!==`local`)return!1;let n=tl(t.source.path);return n===e.path||n.startsWith(`${e.path}/`)};function sl(e,t){return t.filter(t=>ol(e,t))}function cl(e){let t=e.find(e=>e.state.kind===`failed`);if(t&&t.state.kind===`failed`)return{kind:`failed`,error:t.state.error,ref:t.state.ref};let n=e[0];return n?{kind:`active`,version:n.source.kind===`package`?n.source.version:null}:{kind:`notReported`}}function ll(e){let t=e.flatMap(e=>e.source.kind===`package`?[e.source]:[]);return t.some(e=>e.updating)?`updating`:t.some(e=>e.outdated)?`available`:`none`}function ul(e){let t=(0,Ii.c)(18),n=yc(),r;t[0]===n?r=t[1]:(r=()=>{n.refetch()},t[0]=n,t[1]=r);let i=Ae(r),a;bb0:{if(n.isPending&&n.data===void 0){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e={kind:`loading`},t[2]=e):e=t[2],a=e;break bb0}if(n.data===void 0||!e){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e={kind:`unknown`},t[3]=e):e=t[3],a=e;break bb0}let r,i,o;if(t[4]!==n.data||t[5]!==e){let a=sl(e,n.data);r=`known`,i=cl(a),o=ll(a),t[4]=n.data,t[5]=e,t[6]=r,t[7]=i,t[8]=o}else r=t[6],i=t[7],o=t[8];let s;t[9]!==r||t[10]!==i||t[11]!==o||t[12]!==e?(s={kind:r,load:i,update:o,target:e},t[9]=r,t[10]=i,t[11]=o,t[12]=e,t[13]=s):s=t[13],a=s}let o=a,s;return t[14]!==n.isFetching||t[15]!==i||t[16]!==o?(s={status:o,retry:i,isRefreshing:n.isFetching},t[14]=n.isFetching,t[15]=i,t[16]=o,t[17]=s):s=t[17],s}function dl(e){let t=(0,Ii.c)(5),n=vc(),r;t[0]!==n||t[1]!==e?(r=e?.kind===`package`?hc(n,e.target):null,t[0]=n,t[1]=e,t[2]=r):r=t[2];let i=r,a;return t[3]===i?a=t[4]:(a=e=>i?e.packageUpdates[i]??null:null,t[3]=i,t[4]=a),zc(a)}var fl=e=>{let t=(0,Ii.c)(35),{target:n}=e,{t:r}=Me(),{status:i}=ul(n),a=dl(n);if(i.kind!==`known`)return null;let o;bb0:{if(i.update===`updating`||a?.kind===`running`){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(X,{name:`loader-4`,className:`h-3 w-3 animate-spin text-muted-foreground`}),t[0]=e):e=t[0];let n;t[1]===r?n=t[2]:(n=r(`settings.plugins.update.running`),t[1]=r,t[2]=n);let i;t[3]===n?i=t[4]:(i={icon:e,label:n},t[3]=n,t[4]=i),o=i;break bb0}if(i.load.kind===`failed`){let e;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(X,{name:`error-warning`,className:`h-3 w-3 text-[var(--status-error)]`}),t[5]=e):e=t[5];let n;t[6]===r?n=t[7]:(n=r(`settings.plugins.status.failed.title`),t[6]=r,t[7]=n);let i;t[8]===n?i=t[9]:(i={icon:e,label:n},t[8]=n,t[9]=i),o=i;break bb0}if(i.load.kind===`notReported`){let e;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(X,{name:`time`,className:`h-3 w-3 text-muted-foreground`}),t[10]=e):e=t[10];let n;t[11]===r?n=t[12]:(n=r(`settings.plugins.status.notReported.title`),t[11]=r,t[12]=n);let i;t[13]===n?i=t[14]:(i={icon:e,label:n},t[13]=n,t[14]=i),o=i;break bb0}if(i.update===`available`){let e;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(X,{name:`arrow-up-s`,className:`h-3 w-3 text-[var(--status-success)]`}),t[15]=e):e=t[15];let n;t[16]===r?n=t[17]:(n=r(`settings.plugins.update.available.title`),t[16]=r,t[17]=n);let i;t[18]===n?i=t[19]:(i={icon:e,label:n},t[18]=n,t[19]=i),o=i;break bb0}let e;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(X,{name:`checkbox-circle`,className:`h-3 w-3 text-[var(--status-success)]`}),t[20]=e):e=t[20];let n;t[21]!==i.load.version||t[22]!==r?(n=i.load.version?r(`settings.plugins.status.loadedVersion`,{version:i.load.version}):r(`settings.plugins.status.loaded`),t[21]=i.load.version,t[22]=r,t[23]=n):n=t[23];let s;t[24]===n?s=t[25]:(s={icon:e,label:n},t[24]=n,t[25]=s),o=s}let s=o,c;t[26]!==s.icon||t[27]!==s.label||t[28]!==i.load.kind?(c=(0,$.jsx)(pn,{asChild:!0,children:(0,$.jsx)(`span`,{className:`inline-flex shrink-0 items-center`,"aria-label":s.label,"data-plugin-load-state":i.load.kind,children:s.icon})}),t[26]=s.icon,t[27]=s.label,t[28]=i.load.kind,t[29]=c):c=t[29];let l;t[30]===s.label?l=t[31]:(l=(0,$.jsx)(mn,{children:s.label}),t[30]=s.label,t[31]=l);let u;return t[32]!==c||t[33]!==l?(u=(0,$.jsxs)(hn,{children:[c,l]}),t[32]=c,t[33]=l,t[34]=u):u=t[34],u};function pl(e){return e?e.compatibility===`v1-incompatible`||e.compatible===!1:!1}var ml=e=>e.parsedKind===`npm`?`code-box`:`folder`,hl=e=>{let t=(0,Ii.c)(167),{onItemSelect:n,onAddClick:r}=e,{t:i}=Me(),{selectedId:a,setSelected:o,deleteEntry:s,deleteFile:c,loadPlugins:l,updateEntry:u,updatePackage:d,packageUpdates:f}=zc(le(gl)),p=gc();p.data?.entries;let m;t[0]===p.data?.entries?m=t[1]:(m=p.data?.entries??[],t[0]=p.data?.entries,t[1]=m);let h=m,g;t[2]===p.data?.files?g=t[3]:(g=()=>p.data?.files??[],t[2]=p.data?.files,t[3]=g),p.data?.files;let _;t[4]===g?_=t[5]:(_=g(),t[4]=g,t[5]=_);let v=_,y;t[6]===h?y=t[7]:(y=h.map(_l),t[6]=h,t[7]=y);let b=y,{data:x,isFetching:S}=_c(b,!1),C;t[8]===x?C=t[9]:(C=x??{},t[8]=x,t[9]=C);let w=C,T=vc(),E=yc(),D=E.isError&&E.data===void 0,[O,k]=Q.useState(!1),[A,j]=Q.useState(null),[M,N]=Q.useState(!1),[P,F]=Q.useState(!1),I,L;t[10]===l?(I=t[11],L=t[12]):(I=()=>{l()},L=[l],t[10]=l,t[11]=I,t[12]=L),Q.useEffect(I,L);let R,z;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(R=()=>{let e=()=>F(!0);return window.addEventListener(`openchamber:settings-open-plugin-add`,e),()=>window.removeEventListener(`openchamber:settings-open-plugin-add`,e)},z=[],t[13]=R,t[14]=z):(R=t[13],z=t[14]),Q.useEffect(R,z);let B;if(t[15]!==h||t[16]!==v){B=new Map;for(let e of h)B.set(e.id,il(e.spec,e.sourcePath));for(let e of v)B.set(e.id,al(e.absolutePath));t[15]=h,t[16]=v,t[17]=B}else B=t[17];let V=B,H;if(t[18]!==T||t[19]!==h||t[20]!==f||t[21]!==E.data||t[22]!==V){bb0:{let e=E.data,t=new Map;if(!e){H=t;break bb0}for(let n of h){let r=V.get(n.id);r?.kind===`package`&&f[hc(T,r.target)]?.kind!==`running`&&ll(sl(r,e))===`available`&&t.set(n.id,r.target)}H=t}t[18]=T,t[19]=h,t[20]=f,t[21]=E.data,t[22]=V,t[23]=H}else H=t[23];let U=H,W;if(t[24]!==h||t[25]!==U||t[26]!==w){W={userEntries:0,projectEntries:0};for(let e of h){let t=w[e.spec];(t?.kind===`npm-ok`&&t.hasUpdate||U.has(e.id))&&(e.scope===`user`?W.userEntries+=1:e.scope===`project`&&(W.projectEntries+=1))}t[24]=h,t[25]=U,t[26]=w,t[27]=W}else W=t[27];let ee=W,G;t[28]===h?G=t[29]:(G=h.filter(vl),t[28]=h,t[29]=G);let te=G,ne;t[30]===h?ne=t[31]:(ne=h.filter(yl),t[30]=h,t[31]=ne);let re=ne,ie;t[32]===v?ie=t[33]:(ie=v.filter(bl),t[32]=v,t[33]=ie);let ae=ie,oe;t[34]===v?oe=t[35]:(oe=v.filter(xl),t[34]=v,t[35]=oe);let se=oe,ce=h.length+v.length===0,ue;t[36]===r?ue=t[37]:(ue=()=>{r?r():F(!0)},t[36]=r,t[37]=ue);let de=ue,fe;t[38]!==n||t[39]!==o?(fe=e=>{o(e),n?.()},t[38]=n,t[39]=o,t[40]=fe):fe=t[40];let pe=fe,me;t[41]!==h||t[42]!==w||t[43]!==i||t[44]!==u?(me=async e=>{let t=h.find(t=>t.id===e);if(!t)return;let n=w[t.spec];if(!n||n.kind!==`npm-ok`||!n.hasUpdate||!n.latestVersion)return;let r=n.latestVersion;(await u(e,{spec:`${n.name}@${r}`})).ok?Y.success(i(`settings.plugins.toast.updatedToLatest`,{version:r})):Y.error(i(`settings.plugins.toast.refreshFailed`))},t[41]=h,t[42]=w,t[43]=i,t[44]=u,t[45]=me):me=t[45];let he=me,ge;t[46]!==i||t[47]!==d?(ge=async(e,t)=>{await d(e)?Y.success(i(`settings.plugins.update.toast.done`,{name:t})):Y.error(i(`settings.plugins.update.toast.failed`,{name:t}))},t[46]=i,t[47]=d,t[48]=ge):ge=t[48];let _e=Ae(ge),ve;t[49]!==T||t[50]!==b||t[51]!==i?(ve=async()=>{Y.info(i(`settings.plugins.toast.refreshing`)),k(!0);let e=await xc(void 0,zt(),b).then(Sl).catch(Cl),t=await Cc(T).then(wl).catch(Tl);k(!1),e||Y.error(i(`settings.plugins.toast.refreshFailed`)),t||Y.error(i(`settings.plugins.toast.checkFailed`))},t[49]=T,t[50]=b,t[51]=i,t[52]=ve):ve=t[52];let K=Ae(ve),ye;t[53]!==s||t[54]!==c||t[55]!==A||t[56]!==i?(ye=async()=>{if(!A)return;N(!0);let e=A.kind===`entry`?await s(A.id):await c(A.id);e.ok?Y.success(e.message||i(`settings.plugins.sidebar.toast.deleted`,{name:A.label})):Y.error(i(`settings.plugins.sidebar.toast.deleteFailed`)),j(null),N(!1)},t[53]=s,t[54]=c,t[55]=A,t[56]=i,t[57]=ye):ye=t[57];let be=ye,xe;t[58]!==_e||t[59]!==pe||t[60]!==he||t[61]!==U||t[62]!==w||t[63]!==V||t[64]!==a||t[65]!==i?(xe=e=>{let t=w[e.spec],n=t?.kind===`npm-ok`&&t.hasUpdate&&!!t.latestVersion,r=U.get(e.id)??null,o=[];return r?o.push({label:i(`settings.plugins.update.action`),icon:`arrow-up-s`,onClick:()=>void _e(r,e.spec)}):n&&o.push({label:i(`settings.plugins.sidebar.actions.updateToLatest`),icon:`arrow-up-s`,onClick:()=>void he(e.id)}),o.push({label:i(`settings.common.actions.delete`),icon:`delete-bin`,destructive:!0,onClick:()=>j({kind:`entry`,id:e.id,label:e.spec})}),(0,$.jsx)(yo,{title:(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.spec}),(0,$.jsx)(fl,{target:V.get(e.id)??null}),pl(e)?(0,$.jsx)(`span`,{className:`typography-micro shrink-0 rounded-full border border-[var(--status-warning)] px-1.5 py-0.5 text-[var(--status-warning)]`,title:i(`settings.plugins.compatibility.v1Incompatible.tooltip`),children:i(`settings.plugins.compatibility.v1Incompatible`)}):null,(0,$.jsx)(Qc,{info:t})]}),metadata:e.parsedKind===`npm`?i(`settings.plugins.sidebar.kind.npm`):i(`settings.plugins.sidebar.kind.path`),selected:a===e.id,onSelect:()=>pe(e.id),icon:(0,$.jsx)(X,{name:ml(e),className:`h-4 w-4 flex-shrink-0 text-muted-foreground/70`}),actions:o},e.id)},t[58]=_e,t[59]=pe,t[60]=he,t[61]=U,t[62]=w,t[63]=V,t[64]=a,t[65]=i,t[66]=xe):xe=t[66];let Se=xe,Ce;t[67]!==pe||t[68]!==V||t[69]!==a||t[70]!==i?(Ce=e=>(0,$.jsx)(yo,{title:(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.fileName}),(0,$.jsx)(fl,{target:V.get(e.id)??null}),pl(e)?(0,$.jsx)(`span`,{className:`typography-micro shrink-0 rounded-full border border-[var(--status-warning)] px-1.5 py-0.5 text-[var(--status-warning)]`,title:i(`settings.plugins.compatibility.v1Incompatible.tooltip`),children:i(`settings.plugins.compatibility.v1Incompatible`)}):null]}),metadata:i(`settings.plugins.sidebar.kind.file`),selected:a===e.id,onSelect:()=>pe(e.id),icon:(0,$.jsx)(X,{name:`file-text`,className:`h-4 w-4 flex-shrink-0 text-muted-foreground/70`}),actions:[{label:i(`settings.common.actions.delete`),icon:`delete-bin`,destructive:!0,onClick:()=>j({kind:`file`,id:e.id,label:e.fileName})}]},e.id),t[67]=pe,t[68]=V,t[69]=a,t[70]=i,t[71]=Ce):Ce=t[71];let we=Ce,Te;t[72]===i?Te=t[73]:(Te=(e,t,n,r,a)=>{let o=n===void 0?0:n;return(0,$.jsx)(vi,{cardClassName:a!==void 0&&a?`hidden`:void 0,label:(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,$.jsxs)(`span`,{children:[e,o>0&&(0,$.jsx)(`span`,{className:`ml-2 text-[var(--status-success)]`,children:i(o===1?`settings.plugins.sidebar.group.updatesAvailable_one`:`settings.plugins.sidebar.group.updatesAvailable_other`,{count:o})})]}),r]}),children:t})},t[72]=i,t[73]=Te);let Ee=Te,De;t[74]===K?De=t[75]:(De=()=>void K(),t[74]=K,t[75]=De);let Oe=S||E.isFetching||O,ke;t[76]===i?ke=t[77]:(ke=i(`settings.plugins.sidebar.actions.refresh`),t[76]=i,t[77]=ke);let je;t[78]===i?je=t[79]:(je=i(`settings.plugins.sidebar.actions.refresh`),t[78]=i,t[79]=je);let Ne=S||E.isFetching||O?`size-4 animate-spin`:`size-4`,Pe;t[80]===Ne?Pe=t[81]:(Pe=(0,$.jsx)(X,{name:`refresh`,className:Ne}),t[80]=Ne,t[81]=Pe);let q;t[82]!==De||t[83]!==Oe||t[84]!==ke||t[85]!==je||t[86]!==Pe?(q=(0,$.jsx)(J,{type:`button`,variant:`ghost`,size:`icon`,onClick:De,disabled:Oe,"aria-label":ke,title:je,children:Pe}),t[82]=De,t[83]=Oe,t[84]=ke,t[85]=je,t[86]=Pe,t[87]=q):q=t[87];let Fe;t[88]===i?Fe=t[89]:(Fe=i(`settings.plugins.sidebar.actions.addTitle`),t[88]=i,t[89]=Fe);let Ie;t[90]===i?Ie=t[91]:(Ie=i(`settings.plugins.sidebar.actions.addTitle`),t[90]=i,t[91]=Ie);let Le;t[92]===Symbol.for(`react.memo_cache_sentinel`)?(Le=(0,$.jsx)(X,{name:`add`,className:`size-4`}),t[92]=Le):Le=t[92];let Re;t[93]!==de||t[94]!==Fe||t[95]!==Ie?(Re=(0,$.jsx)(J,{"data-settings-item":`plugins.create`,type:`button`,variant:`ghost`,size:`icon`,onClick:de,"aria-label":Fe,title:Ie,children:Le}),t[93]=de,t[94]=Fe,t[95]=Ie,t[96]=Re):Re=t[96];let ze;t[97]!==q||t[98]!==Re?(ze=(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[q,Re]}),t[97]=q,t[98]=Re,t[99]=ze):ze=t[99];let Be=ze,Ve;t[100]!==D||t[101]!==i?(Ve=D?(0,$.jsxs)(`p`,{className:`typography-micro mb-2 flex items-center gap-1 text-muted-foreground`,role:`status`,children:[(0,$.jsx)(X,{name:`question`,className:`size-3 shrink-0`}),i(`settings.plugins.status.sidebar.unavailable`)]}):void 0,t[100]=D,t[101]=i,t[102]=Ve):Ve=t[102];let He;t[103]!==Be||t[104]!==Se||t[105]!==Ee||t[106]!==i||t[107]!==ee||t[108]!==te?(He=te.length>0?Ee(i(`settings.plugins.sidebar.group.userEntries`),te.map(Se),ee.userEntries,Be):Ee(i(`settings.plugins.sidebar.group.userEntries`),(0,$.jsx)(`span`,{}),0,Be,!0),t[103]=Be,t[104]=Se,t[105]=Ee,t[106]=i,t[107]=ee,t[108]=te,t[109]=He):He=t[109];let Ue;t[110]!==ce||t[111]!==re||t[112]!==se||t[113]!==Se||t[114]!==we||t[115]!==Ee||t[116]!==i||t[117]!==ee||t[118]!==ae?(Ue=ce?(0,$.jsx)(vi,{children:(0,$.jsxs)(`div`,{className:`oc-settings-group-row py-12 text-center text-muted-foreground`,children:[(0,$.jsx)(X,{name:`plug`,className:`mx-auto mb-3 h-10 w-10 opacity-50`}),(0,$.jsx)(`p`,{className:`typography-ui-label font-medium`,children:i(`settings.plugins.sidebar.empty.title`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 opacity-75`,children:i(`settings.plugins.sidebar.empty.description`)})]})}):(0,$.jsxs)($.Fragment,{children:[ae.length>0&&Ee(i(`settings.plugins.sidebar.group.userFiles`),ae.map(we)),re.length>0&&Ee(i(`settings.plugins.sidebar.group.projectEntries`),re.map(Se),ee.projectEntries),se.length>0&&Ee(i(`settings.plugins.sidebar.group.projectFiles`),se.map(we))]}),t[110]=ce,t[111]=re,t[112]=se,t[113]=Se,t[114]=we,t[115]=Ee,t[116]=i,t[117]=ee,t[118]=ae,t[119]=Ue):Ue=t[119];let We;t[120]!==Ve||t[121]!==He||t[122]!==Ue?(We=(0,$.jsxs)(xo,{variant:`background`,header:Ve,children:[He,Ue]}),t[120]=Ve,t[121]=He,t[122]=Ue,t[123]=We):We=t[123];let Ge;t[124]===P?Ge=t[125]:(Ge=(0,$.jsx)(Zc,{open:P,onOpenChange:F}),t[124]=P,t[125]=Ge);let Ke=A!==null,qe;t[126]===M?qe=t[127]:(qe=e=>{!e&&!M&&j(null)},t[126]=M,t[127]=qe);let Je;t[128]===i?Je=t[129]:(Je=i(`settings.plugins.sidebar.deleteDialog.title`),t[128]=i,t[129]=Je);let Ye;t[130]===Je?Ye=t[131]:(Ye=(0,$.jsx)(Xt,{children:Je}),t[130]=Je,t[131]=Ye);let Xe=A?.label??``,Ze;t[132]!==i||t[133]!==Xe?(Ze=i(`settings.plugins.sidebar.deleteDialog.description`,{name:Xe}),t[132]=i,t[133]=Xe,t[134]=Ze):Ze=t[134];let Qe;t[135]===Ze?Qe=t[136]:(Qe=(0,$.jsx)(Zt,{children:Ze}),t[135]=Ze,t[136]=Qe);let $e;t[137]!==Ye||t[138]!==Qe?($e=(0,$.jsxs)(qt,{children:[Ye,Qe]}),t[137]=Ye,t[138]=Qe,t[139]=$e):$e=t[139];let et;t[140]===Symbol.for(`react.memo_cache_sentinel`)?(et=()=>j(null),t[140]=et):et=t[140];let tt;t[141]===i?tt=t[142]:(tt=i(`settings.common.actions.cancel`),t[141]=i,t[142]=tt);let nt;t[143]!==M||t[144]!==tt?(nt=(0,$.jsx)(J,{size:`sm`,variant:`ghost`,onClick:et,disabled:M,children:tt}),t[143]=M,t[144]=tt,t[145]=nt):nt=t[145];let rt;t[146]!==M||t[147]!==i?(rt=i(M?`settings.plugins.sidebar.actions.deleting`:`settings.common.actions.delete`),t[146]=M,t[147]=i,t[148]=rt):rt=t[148];let it;t[149]!==be||t[150]!==M||t[151]!==rt?(it=(0,$.jsx)(J,{size:`sm`,variant:`destructive`,onClick:be,disabled:M,children:rt}),t[149]=be,t[150]=M,t[151]=rt,t[152]=it):it=t[152];let at;t[153]!==nt||t[154]!==it?(at=(0,$.jsxs)(Jt,{children:[nt,it]}),t[153]=nt,t[154]=it,t[155]=at):at=t[155];let ot;t[156]!==$e||t[157]!==at?(ot=(0,$.jsxs)(Yt,{className:`max-w-md`,children:[$e,at]}),t[156]=$e,t[157]=at,t[158]=ot):ot=t[158];let st;t[159]!==Ke||t[160]!==qe||t[161]!==ot?(st=(0,$.jsx)(Qt,{open:Ke,onOpenChange:qe,children:ot}),t[159]=Ke,t[160]=qe,t[161]=ot,t[162]=st):st=t[162];let ct;return t[163]!==We||t[164]!==Ge||t[165]!==st?(ct=(0,$.jsxs)($.Fragment,{children:[We,Ge,st]}),t[163]=We,t[164]=Ge,t[165]=st,t[166]=ct):ct=t[166],ct};function gl(e){return{selectedId:e.selectedId,setSelected:e.setSelected,deleteEntry:e.deleteEntry,deleteFile:e.deleteFile,loadPlugins:e.loadPlugins,updateEntry:e.updateEntry,updatePackage:e.updatePackage,packageUpdates:e.packageUpdates}}function _l(e){return e.spec}function vl(e){return e.scope===`user`}function yl(e){return e.scope===`project`}function bl(e){return e.scope===`user`}function xl(e){return e.scope===`project`}function Sl(){return!0}function Cl(){return!1}function wl(){return!0}function Tl(){return!1}var El=e=>{let t=(0,Ii.c)(10),{children:n,className:r,outerClassName:i}=e,a;t[0]===i?a=t[1]:(a=q(`h-full`,i),t[0]=i,t[1]=a);let o;t[2]===r?o=t[3]:(o=q(`oc-settings-page-content mx-auto max-w-3xl p-3 sm:p-6 sm:pt-8`,r),t[2]=r,t[3]=o);let s;t[4]!==n||t[5]!==o?(s=(0,$.jsx)(`div`,{className:o,children:n}),t[4]=n,t[5]=o,t[6]=s):s=t[6];let c;return t[7]!==a||t[8]!==s?(c=(0,$.jsx)(Sr,{outerClassName:a,className:`w-full`,children:s}),t[7]=a,t[8]=s,t[9]=c):c=t[9],c},Dl=({entryId:e,spec:t})=>{let{t:n}=Me(),{data:r}=_c([t]),i=r?.[t],a=zc(e=>e.updateEntry),[o,s]=Q.useState(!1);if(!i)return null;if(i.kind===`npm-ok`){if(!i.hasUpdate||!i.latestVersion)return null;let t=i.latestVersion,r=i.currentVersion??``,c=async()=>{s(!0);try{(await a(e,{spec:`${i.name}@latest`})).ok?Y.success(n(`settings.plugins.toast.updatedToLatest`,{version:t})):Y.error(n(`settings.plugins.toast.refreshFailed`))}finally{s(!1)}};return(0,$.jsxs)(`div`,{className:`rounded-md border border-border bg-card p-3 flex items-start gap-3`,children:[(0,$.jsx)(X,{name:`arrow-up`,className:`h-5 w-5 text-[var(--status-success)] shrink-0 mt-0.5`}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,$.jsx)(`p`,{className:`typography-label text-[var(--status-success)]`,children:n(`settings.plugins.registry.banner.updateAvailable.title`)}),(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground mt-0.5`,children:n(`settings.plugins.registry.banner.updateAvailable.description`,{current:r,latest:t})})]}),(0,$.jsx)(J,{variant:`default`,size:`sm`,onClick:()=>void c(),disabled:o,children:n(`settings.plugins.registry.banner.updateAvailable.action`,{latest:t})})]})}if(i.kind===`path-ok`)return null;if(i.kind===`npm-network`)return(0,$.jsxs)(`div`,{className:`rounded-md border border-border bg-card p-3 flex items-start gap-3`,children:[(0,$.jsx)(X,{name:`cloud-off`,className:`h-5 w-5 text-muted-foreground shrink-0 mt-0.5`}),(0,$.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground`,children:n(`settings.plugins.registry.badge.network.tooltip`)})})]});let c=i.kind===`path-unreadable`,l=c?`var(--status-warning)`:`var(--status-error)`,u=c?`alert`:`error-warning`,d=(()=>{switch(i.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(0,$.jsxs)(`div`,{className:`rounded-md border border-border bg-card p-3 flex items-start gap-3`,children:[(0,$.jsx)(X,{name:u,className:`h-5 w-5 shrink-0 mt-0.5`,style:{color:l}}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,$.jsx)(`p`,{className:`typography-label`,style:{color:l},children:n(`settings.plugins.registry.banner.invalid.title`)}),(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground mt-0.5`,children:d})]})]})},Ol=e=>{let t=(0,Ii.c)(69),{target:n,name:r}=e,{t:i}=Me(),{status:a,retry:o,isRefreshing:s}=ul(n),c=dl(n),l=zc(kl),u=a.kind===`known`&&a.target.kind===`package`?a.target.target:null,d=a.kind===`known`&&(a.update===`updating`||c?.kind===`running`),f;t[0]===o?f=t[1]:(f=()=>{o()},t[0]=o,t[1]=f);let p=Ae(f),m;t[2]!==r||t[3]!==u||t[4]!==i||t[5]!==l?(m=async()=>{u&&(await l(u)?Y.success(i(`settings.plugins.update.toast.done`,{name:r})):Y.error(i(`settings.plugins.update.toast.failed`,{name:r})))},t[2]=r,t[3]=u,t[4]=i,t[5]=l,t[6]=m):m=t[6];let h=Ae(m);if(a.kind===`loading`)return null;if(a.kind===`unknown`){let e;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(X,{name:`question`,className:`mt-0.5 h-5 w-5 shrink-0 text-muted-foreground`}),t[7]=e):e=t[7];let n;t[8]===i?n=t[9]:(n=i(`settings.plugins.status.unknown.title`),t[8]=i,t[9]=n);let r;t[10]===n?r=t[11]:(r=(0,$.jsx)(`p`,{className:`typography-label text-foreground`,children:n}),t[10]=n,t[11]=r);let a;t[12]===i?a=t[13]:(a=i(`settings.plugins.status.unknown.description`),t[12]=i,t[13]=a);let o;t[14]===a?o=t[15]:(o=(0,$.jsx)(`p`,{className:`typography-micro mt-0.5 text-muted-foreground`,children:a}),t[14]=a,t[15]=o);let c;t[16]!==r||t[17]!==o?(c=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[r,o]}),t[16]=r,t[17]=o,t[18]=c):c=t[18];let l;t[19]===i?l=t[20]:(l=i(`settings.plugins.status.retry`),t[19]=i,t[20]=l);let u;t[21]!==p||t[22]!==s||t[23]!==l?(u=(0,$.jsx)(J,{variant:`outline`,size:`sm`,onClick:p,disabled:s,children:l}),t[21]=p,t[22]=s,t[23]=l,t[24]=u):u=t[24];let d;return t[25]!==u||t[26]!==c?(d=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-start gap-3 rounded-md border border-border bg-card p-3`,role:`status`,"data-plugin-load-state":`unknown`,children:[e,c,u]}),t[25]=u,t[26]=c,t[27]=d):d=t[27],d}let{load:g,update:_}=a,v=u!==null&&(_!==`none`||c!==null),y;bb0:{switch(g.kind){case`active`:{let e;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(X,{name:`checkbox-circle`,className:`h-4 w-4 text-[var(--status-success)]`}),t[28]=e):e=t[28];let n;t[29]!==g.version||t[30]!==i?(n=g.version?i(`settings.plugins.status.loadedVersion`,{version:g.version}):i(`settings.plugins.status.loaded`),t[29]=g.version,t[30]=i,t[31]=n):n=t[31];let r;t[32]===n?r=t[33]:(r=(0,$.jsxs)(`p`,{className:`typography-meta flex items-center gap-1.5 text-muted-foreground`,role:`status`,"data-plugin-load-state":`active`,children:[e,n]}),t[32]=n,t[33]=r),y=r;break bb0}case`notReported`:{let e;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(X,{name:`time`,className:`mt-0.5 h-5 w-5 shrink-0 text-muted-foreground`}),t[34]=e):e=t[34];let n;t[35]===i?n=t[36]:(n=i(`settings.plugins.status.notReported.title`),t[35]=i,t[36]=n);let r;t[37]===n?r=t[38]:(r=(0,$.jsx)(`p`,{className:`typography-label text-foreground`,children:n}),t[37]=n,t[38]=r);let a;t[39]===i?a=t[40]:(a=i(`settings.plugins.status.notReported.description`),t[39]=i,t[40]=a);let o;t[41]===a?o=t[42]:(o=(0,$.jsx)(`p`,{className:`typography-micro mt-0.5 text-muted-foreground`,children:a}),t[41]=a,t[42]=o);let s;t[43]!==r||t[44]!==o?(s=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-start gap-3 rounded-md border border-border bg-card p-3`,role:`status`,"data-plugin-load-state":`notReported`,children:[e,(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[r,o]})]}),t[43]=r,t[44]=o,t[45]=s):s=t[45],y=s;break bb0}case`failed`:{let e;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(X,{name:`error-warning`,className:`mt-0.5 h-5 w-5 shrink-0 text-[var(--status-error)]`}),t[46]=e):e=t[46];let n;t[47]===i?n=t[48]:(n=i(`settings.plugins.status.failed.title`),t[47]=i,t[48]=n);let r;t[49]===n?r=t[50]:(r=(0,$.jsx)(`p`,{className:`typography-label text-[var(--status-error)]`,children:n}),t[49]=n,t[50]=r);let a;t[51]===g.error?a=t[52]:(a=(0,$.jsx)(`p`,{className:`typography-micro mt-1 whitespace-pre-wrap break-words font-mono text-foreground`,children:g.error}),t[51]=g.error,t[52]=a);let o;t[53]!==g.ref||t[54]!==i?(o=g.ref?(0,$.jsx)(`p`,{className:`typography-micro mt-1 text-muted-foreground`,children:i(`settings.plugins.status.failed.ref`,{ref:g.ref})}):null,t[53]=g.ref,t[54]=i,t[55]=o):o=t[55];let s;t[56]!==r||t[57]!==a||t[58]!==o?(s=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-start gap-3 rounded-md border border-border bg-card p-3`,role:`alert`,"data-plugin-load-state":`failed`,children:[e,(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[r,a,o]})]}),t[56]=r,t[57]=a,t[58]=o,t[59]=s):s=t[59],y=s;break bb0}}y=void 0}let b=y,x;t[60]!==h||t[61]!==d||t[62]!==c||t[63]!==v||t[64]!==i?(x=v?(0,$.jsxs)(`div`,{className:`flex flex-wrap items-start gap-3 rounded-md border border-border bg-card p-3`,children:[(0,$.jsx)(X,{name:`arrow-up`,className:`mt-0.5 h-5 w-5 shrink-0 text-[var(--status-success)]`}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`p`,{className:`typography-label text-[var(--status-success)]`,children:i(`settings.plugins.update.available.title`)}),(0,$.jsx)(`p`,{className:`typography-micro mt-0.5 text-muted-foreground`,children:i(`settings.plugins.update.available.description`)}),c?.kind===`failed`?(0,$.jsxs)(`div`,{className:`mt-2`,role:`alert`,children:[(0,$.jsx)(`p`,{className:`typography-micro text-[var(--status-error)]`,children:i(`settings.plugins.update.failed.title`)}),(0,$.jsx)(`p`,{className:`typography-micro mt-0.5 whitespace-pre-wrap break-words font-mono text-foreground`,children:c.error})]}):null]}),(0,$.jsx)(J,{variant:`default`,size:`sm`,onClick:()=>void h(),disabled:d,children:d?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(X,{name:`loader-4`,className:`size-4 animate-spin`}),i(`settings.plugins.update.running`)]}):i(`settings.plugins.update.action`)})]}):null,t[60]=h,t[61]=d,t[62]=c,t[63]=v,t[64]=i,t[65]=x):x=t[65];let S;return t[66]!==b||t[67]!==x?(S=(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[b,x]}),t[66]=b,t[67]=x,t[68]=S):S=t[68],S};function kl(e){return e.updatePackage}function Al(e){let t=e.trim();if(t.length===0)return{ok:!0,value:void 0};try{let e=JSON.parse(t);return typeof e!=`object`||!e||Array.isArray(e)?{ok:!1}:{ok:!0,value:e}}catch{return{ok:!1}}}function jl(e){return!e||Object.keys(e).length===0?``:JSON.stringify(e,null,2)}function Ml(e){return{mode:`entry`,scope:e.scope,spec:e.spec,optionsJson:jl(e.options),fileName:``,content:``}}function Nl(e,t){return{mode:`file`,scope:e.scope,spec:``,optionsJson:``,fileName:e.fileName,content:t}}var Pl=e=>{let t=(0,Ii.c)(4),{scope:n,label:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=q(`typography-micro font-medium rounded-full px-2 py-0.5`,`bg-[var(--surface-elevated)] text-muted-foreground`,`border border-[var(--interactive-border)]`),t[0]=i):i=t[0];let a;return t[1]!==r||t[2]!==n?(a=(0,$.jsx)(`span`,{className:i,"data-scope":n,children:r}),t[1]=r,t[2]=n,t[3]=a):a=t[3],a},Fl=()=>{let{t:e}=Me(),t=zc(e=>e.selectedId),n=gc(),r=Q.useMemo(()=>n.data?.entries??[],[n.data?.entries]),i=Q.useMemo(()=>n.data?.files??[],[n.data?.files]),a=zc(e=>e.draft),o=zc(e=>e.setDraft),s=zc(e=>e.updateEntry),c=zc(e=>e.updateFile),l=zc(e=>e.readFile),u=Q.useMemo(()=>t?r.find(e=>e.id===t)??null:null,[r,t]),d=Q.useMemo(()=>t?i.find(e=>e.id===t)??null:null,[i,t]),f=Q.useMemo(()=>u?il(u.spec,u.sourcePath):null,[u]),p=Q.useMemo(()=>d?al(d.absolutePath):null,[d]),[m,h]=Q.useState(!1),[g,_]=Q.useState(!1),v=Q.useRef(new Map);if(Q.useEffect(()=>{let e=!1;return u?(o(Ml(u)),()=>{e=!0}):d?(_(!0),(async()=>{let t=await l(d.id);if(e)return;_(!1);let n=t?.content??``;v.current.set(d.id,n),o(Nl(d,n))})(),()=>{e=!0}):(o(null),()=>{e=!0})},[u,d,l,o]),!t)return(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,$.jsxs)(`div`,{className:`text-center text-muted-foreground`,children:[(0,$.jsx)(X,{name:`plug`,className:`mx-auto mb-3 h-12 w-12 opacity-50`}),(0,$.jsx)(`p`,{className:`typography-body`,children:e(`settings.plugins.page.empty.select`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 opacity-75`,children:e(`settings.plugins.page.empty.add`)})]})});if(u&&a&&a.mode===`entry`){let t=Al(a.optionsJson),n=t.ok,r=a.spec!==u.spec||a.optionsJson!==jl(u.options),i=()=>{o(Ml(u))},c=async()=>{if(!n)return;let r=a.spec.trim();if(!r){Y.error(e(`settings.plugins.validation.specRequired`));return}h(!0);try{let n=await s(u.id,{spec:r,options:t.value});n.ok?n.reloadFailed?Y.warning(n.message||e(`settings.plugins.toast.reloadFailed`),{description:n.warning}):Y.success(n.message||e(`settings.plugins.toast.updated`)):Y.error(n.message||e(`settings.plugins.toast.reloadFailed`))}finally{h(!1)}};return(0,$.jsxs)(El,{children:[(0,$.jsx)(`div`,{children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,$.jsx)(`h2`,{className:`typography-ui-header font-semibold text-foreground truncate`,children:e(`settings.plugins.page.header.entry`)}),(0,$.jsx)(Pl,{scope:u.scope,label:u.scope===`project`?e(`settings.plugins.sidebar.group.projectEntries`):e(`settings.plugins.sidebar.group.userEntries`)})]})}),(0,$.jsx)(Ol,{target:f,name:u.spec}),pl(u)?(0,$.jsxs)(`div`,{className:`rounded-md border border-[var(--status-warning)] bg-card p-3`,children:[(0,$.jsx)(`p`,{className:`typography-label text-[var(--status-warning)]`,children:e(`settings.plugins.registry.banner.v1Incompatible.title`)}),(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground mt-0.5`,children:e(`settings.plugins.registry.banner.v1Incompatible.description`)})]}):null,(0,$.jsx)(Dl,{entryId:u.id,spec:u.spec}),(0,$.jsx)(`div`,{"data-settings-item":`plugins.spec`,children:(0,$.jsx)(vi,{label:e(`settings.plugins.page.field.spec`),cardClassName:`p-3`,children:(0,$.jsx)(fn,{value:a.spec,onChange:e=>o({...a,spec:e.target.value}),placeholder:e(`settings.plugins.page.field.spec.placeholder`),className:`font-mono typography-meta`,spellCheck:!1})})}),(0,$.jsx)(`div`,{"data-settings-item":`plugins.options`,children:(0,$.jsx)(vi,{label:e(`settings.plugins.page.field.options`),description:n?void 0:e(`settings.plugins.page.field.options.invalidJson`),cardClassName:`p-3`,children:(0,$.jsx)(Cr,{embedded:!0,value:a.optionsJson,onChange:e=>o({...a,optionsJson:e.target.value}),rows:10,className:q(`font-mono typography-meta min-h-[200px]`,!n&&`border-[var(--status-error-border)]`),spellCheck:!1,placeholder:`{ }`})})}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(J,{variant:`default`,size:`sm`,onClick:()=>void c(),disabled:!r||!n||m,children:e(`settings.plugins.page.action.save`)}),(0,$.jsx)(J,{variant:`outline`,size:`sm`,onClick:i,disabled:!r||m,children:e(`settings.plugins.page.action.discard`)})]})]})}if(d&&a&&a.mode===`file`){let t=v.current.get(d.id)??``,n=a.content!==t||a.fileName!==d.fileName,r=()=>{(async()=>{_(!0);let e=(await l(d.id))?.content??``;_(!1),v.current.set(d.id,e),o(Nl(d,e))})()},i=async()=>{h(!0);try{let t=await c(d.id,{content:a.content});t.ok?(v.current.set(d.id,a.content),t.reloadFailed?Y.warning(t.message||e(`settings.plugins.toast.reloadFailed`),{description:t.warning}):Y.success(t.message||e(`settings.plugins.toast.updated`))):Y.error(t.message||e(`settings.plugins.toast.reloadFailed`))}finally{h(!1)}};return(0,$.jsxs)(El,{children:[(0,$.jsx)(`div`,{children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0 flex-wrap`,children:[(0,$.jsx)(`h2`,{className:`typography-ui-header font-semibold text-foreground truncate`,children:e(`settings.plugins.page.header.file`)}),(0,$.jsx)(Pl,{scope:d.scope,label:d.scope===`project`?e(`settings.plugins.sidebar.group.projectFiles`):e(`settings.plugins.sidebar.group.userFiles`)}),(0,$.jsx)(`span`,{className:q(`typography-micro font-mono rounded-full px-2 py-0.5`,`bg-[var(--surface-elevated)] text-foreground`,`border border-[var(--interactive-border)]`),children:d.fileName})]})}),(0,$.jsx)(Ol,{target:p,name:d.fileName}),pl(d)?(0,$.jsxs)(`div`,{className:`rounded-md border border-[var(--status-warning)] bg-card p-3`,children:[(0,$.jsx)(`p`,{className:`typography-label text-[var(--status-warning)]`,children:e(`settings.plugins.registry.banner.v1Incompatible.title`)}),(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground mt-0.5`,children:e(`settings.plugins.registry.banner.v1Incompatible.description`)})]}):null,(0,$.jsx)(`div`,{"data-settings-item":`plugins.content`,children:(0,$.jsx)(vi,{label:e(`settings.plugins.page.field.content`),cardClassName:`p-3`,children:(0,$.jsx)(Cr,{embedded:!0,value:a.content,onChange:e=>o({...a,content:e.target.value}),rows:16,className:`font-mono typography-meta min-h-[320px]`,spellCheck:!1,disabled:g})})}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(J,{variant:`default`,size:`sm`,onClick:()=>void i(),disabled:!n||m||g,children:e(`settings.plugins.page.action.save`)}),(0,$.jsx)(J,{variant:`outline`,size:`sm`,onClick:r,disabled:m||g,children:e(`settings.plugins.page.action.discard`)})]})]})}return(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,$.jsx)(`div`,{className:`text-center text-muted-foreground`,children:(0,$.jsx)(X,{name:`loader-4`,className:`mx-auto mb-3 h-6 w-6 animate-spin opacity-50`})})})},Il={opencode:`OpenCode`,"oh-my-opencode-slim":`oh-my-opencode-slim`,"oh-my-openagent":`oh-my-openagent`};async function Ll(e,t){let n=await e.json().catch(()=>null);return typeof n?.error==`string`&&n.error.trim()?n.error:t}function Rl(){let{t:e}=Me(),{currentTheme:t}=vr(),[n,r]=Q.useState([]),[i,a]=Q.useState(null),[o,s]=Q.useState(``),[c,u]=Q.useState(``),[d,f]=Q.useState(``),[p,m]=Q.useState(!0),[h,g]=Q.useState(!1),[_,v]=Q.useState(!1),[y,b]=Q.useState(!1),x=Q.useMemo(()=>{let e=d||`opencode.json`,n=e.endsWith(`.jsonc`)?`jsonc`:`json`,r=[Gr(t,{syntaxColors:!1})],i=Rn(e);return i&&r.push(i),r.push(Wr({language:n,themeName:t.metadata.id,theme:Dr(t)})),r},[t,d]),S=Q.useCallback(async t=>{m(!0);try{let n=await l(`/api/config/global/${t}`);if(!n.ok)throw Error(await Ll(n,e(`settings.globalConfig.toast.loadFailed`)));let r=await n.json(),i=typeof r.content==`string`?r.content:``;s(i),u(i),f(typeof r.fileName==`string`?r.fileName:``)}catch(t){s(``),u(``),f(``),Y.error(t instanceof Error?t.message:e(`settings.globalConfig.toast.loadFailed`))}finally{m(!1)}},[e]);Q.useEffect(()=>{let t=!1;return(async()=>{m(!0);try{let n=await l(`/api/config/global`);if(!n.ok)throw Error(await Ll(n,e(`settings.globalConfig.toast.loadFailed`)));let i=await n.json(),o=Array.isArray(i.targets)?i.targets.flatMap(e=>{if(!e||typeof e!=`object`)return[];let t=e;if(typeof t.target!=`string`||typeof t.fileName!=`string`||!(t.target in Il))return[];let n=t.target;return[{id:n,label:Il[n],fileName:t.fileName}]}):[];if(t)return;r(o),a(e=>o.some(t=>t.id===e)?e:o[0]?.id||null)}catch(n){t||(r([]),a(null),Y.error(n instanceof Error?n.message:e(`settings.globalConfig.toast.loadFailed`)))}finally{t||m(!1)}})(),()=>{t=!0}},[e]),Q.useEffect(()=>{i&&S(i)},[S,i]);let C=async()=>{if(i){g(!0);try{let t=await l(`/api/config/global/${i}`,{method:`PUT`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({content:o})});if(!t.ok)throw Error(await Ll(t,e(`settings.globalConfig.toast.saveFailed`)));let n=await t.json(),r=typeof n.content==`string`?n.content:o;s(r),u(r),Y.success(e(`settings.globalConfig.toast.saved`)),v(n.requiresManualRestart===!0)}catch(t){Y.error(t instanceof Error?t.message:e(`settings.globalConfig.toast.saveFailed`))}finally{g(!1)}}},w=async()=>{b(!0);try{await pt({message:e(`settings.view.actions.reloadOpenCode`),mode:`projects`,scopes:[`all`]}),v(!1)}catch(t){Y.error(t instanceof Error?t.message:e(`settings.view.actions.reloadOpenCode`))}finally{b(!1)}};return(0,$.jsxs)(Sr,{outerClassName:`h-full`,className:`w-full`,children:[(0,$.jsx)(`div`,{className:`oc-settings-page-content mx-auto w-full max-w-4xl p-3 sm:p-6 sm:pt-8`,children:(0,$.jsx)(vi,{itemId:`global-config.editor`,label:e(`settings.globalConfig.title`),description:e(`settings.globalConfig.description`),cardClassName:`p-3`,children:n.length>0?(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(`div`,{className:`flex flex-wrap items-center gap-1`,children:n.map(e=>(0,$.jsx)(J,{variant:`chip`,size:`xs`,"aria-pressed":i===e.id,onClick:()=>a(e.id),children:e.label},e.id))}),(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3 px-1`,children:[(0,$.jsx)(`span`,{className:`typography-meta truncate text-muted-foreground`,children:d}),i&&(0,$.jsx)(J,{variant:`ghost`,size:`xs`,onClick:()=>void S(i),disabled:p||h,children:e(`settings.globalConfig.actions.reload`)})]}),i&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`h-[clamp(420px,62dvh,760px)] overflow-hidden bg-background`,children:(0,$.jsx)(qr,{value:o,onChange:s,readOnly:p,extensions:x,className:`h-full`,enableSearch:!0})}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,$.jsx)(J,{onClick:C,disabled:p||h||o===c,size:`sm`,children:e(h?`settings.common.actions.saving`:`settings.common.actions.saveChanges`)}),i!==`opencode`&&(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:e(`settings.globalConfig.restartHint`)})]})]})]}):(0,$.jsx)(`div`,{className:`min-h-12`,"aria-busy":p})})}),(0,$.jsx)(Qt,{open:_,onOpenChange:e=>!y&&v(e),children:(0,$.jsxs)(Yt,{className:`max-w-md`,children:[(0,$.jsxs)(qt,{children:[(0,$.jsx)(Xt,{children:e(`settings.view.actions.reloadOpenCode`)}),(0,$.jsx)(Zt,{children:e(`settings.globalConfig.restartHint`)})]}),(0,$.jsxs)(Jt,{children:[(0,$.jsx)(J,{variant:`ghost`,size:`sm`,onClick:()=>v(!1),disabled:y,children:e(`settings.common.actions.cancel`)}),(0,$.jsx)(J,{size:`sm`,onClick:()=>void w(),disabled:y,children:e(`settings.view.actions.reloadOpenCode`)})]})]})})]})}var zl=`<built-in>`,Bl=e=>e?.path===zl,Vl=e=>{let t=(0,Ii.c)(172),{onItemSelect:n}=e,{t:r}=Me(),[i,a]=Q.useState(null),[o,s]=Q.useState(``),[c,l]=Q.useState(null),[u,d]=Q.useState(!1),[f,p]=Q.useState(null),{selectedSkillName:m,setSelectedSkill:h,setSkillDraft:g,createSkill:_,deleteSkill:v,getSkillDetail:y}=ma(le(Ul)),b=ft(),x;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(x=dt(),t[0]=x):x=t[0];let S=x,C;t[1]===b.data?C=t[2]:(C=b.data??[],t[1]=b.data,t[2]=C);let w=C,T;t[3]!==n||t[4]!==h||t[5]!==g||t[6]!==w?(T=()=>{let e=`new-skill`,t=1;for(;w.some(t=>t.name===e);)e=`new-skill-${t}`,t++;g({name:e,scope:`user`,source:`opencode`,description:``}),h(e),n?.()},t[3]=n,t[4]=h,t[5]=g,t[6]=w,t[7]=T):T=t[7];let E=T,D;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(D=async e=>{Bl(e)||l(e)},t[8]=D):D=t[8];let O=D,k;t[9]!==c||t[10]!==v||t[11]!==r?(k=async()=>{if(c){if(Bl(c)){l(null);return}d(!0),await v(c.name,{directory:S})?(Y.success(r(`settings.skills.sidebar.toast.skillDeleted`,{name:c.name})),l(null)):Y.error(r(`settings.skills.sidebar.toast.deleteSkillFailed`)),d(!1)}},t[9]=c,t[10]=v,t[11]=r,t[12]=k):k=t[12];let A=k,j;t[13]!==y||t[14]!==h||t[15]!==g||t[16]!==w||t[17]!==r?(j=async e=>{if(Bl(e))return;let t=e.name,n=1,i=`${t}-copy`;for(;w.some(e=>e.name===i);)n++,i=`${t}-copy-${n}`;let a=await y(e.name);if(!a){Y.error(r(`settings.skills.sidebar.toast.duplicateLoadFailed`));return}g({name:i,scope:e.scope||`user`,source:e.source||`opencode`,description:(a.sources.md.fields.includes(`description`),``),instructions:``}),h(i)},t[13]=y,t[14]=h,t[15]=g,t[16]=w,t[17]=r,t[18]=j):j=t[18];let M=j,N;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(N=e=>{Bl(e)||(s(e.name),a(e))},t[19]=N):N=t[19];let P=N,F;t[20]!==_||t[21]!==v||t[22]!==y||t[23]!==i||t[24]!==o||t[25]!==h||t[26]!==w||t[27]!==r?(F=async()=>{if(!i)return;if(Bl(i)){a(null);return}let e=o.trim().replace(/\s+/g,`-`).toLowerCase();if(!e){Y.error(r(`settings.skills.page.toast.skillNameRequired`));return}if(e===i.name){a(null);return}if(w.some(t=>t.name===e)){Y.error(r(`settings.skills.page.toast.skillExists`));return}if(!await y(i.name)){Y.error(r(`settings.skills.sidebar.toast.renameLoadFailed`)),a(null);return}await _({name:e,description:`Renamed skill`,scope:i.scope,source:i.source},{directory:S})?await v(i.name,{directory:S})?(Y.success(`Skill renamed to "${e}"`),h(e)):Y.error(r(`settings.skills.sidebar.toast.removeOldAfterRenameFailed`)):Y.error(r(`settings.skills.sidebar.toast.renameFailed`)),a(null)},t[20]=_,t[21]=v,t[22]=y,t[23]=i,t[24]=o,t[25]=h,t[26]=w,t[27]=r,t[28]=F):F=t[28];let I=F,L;t[29]===w?L=t[30]:(L=w.filter(Wl),t[29]=w,t[30]=L);let R=L,z;t[31]===w?z=t[32]:(z=w.filter(Gl),t[31]=w,t[32]=z);let B=z,V;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(V=function(e){let t={},n=[];for(let r of e)r.group?(t[r.group]||(t[r.group]=[]),t[r.group].push(r)):n.push(r);let r=Object.keys(t).sort(Kl).map(e=>({name:e,skills:[...t[e]].sort(ql)}));return n.sort(Jl),{sortedGroups:r,ungrouped:n}},t[33]=V):V=t[33];let H=V,U;t[34]===R?U=t[35]:(U=H(R),t[34]=R,t[35]=U);let W=U,ee;t[36]===B?ee=t[37]:(ee=H(B),t[36]=B,t[37]=ee);let G=ee,te;t[38]===r?te=t[39]:(te=r(`settings.skills.sidebar.section.project`),t[38]=r,t[39]=te);let ne=te,re;t[40]===r?re=t[41]:(re=r(`settings.skills.sidebar.section.user`),t[40]=r,t[41]=re);let ie=re,ae;t[42]===ne?ae=t[43]:(ae=(0,$.jsx)(`span`,{children:ne}),t[42]=ne,t[43]=ae);let oe;t[44]===r?oe=t[45]:(oe=r(`settings.skills.page.title.newSkill`),t[44]=r,t[45]=oe);let se;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(se=(0,$.jsx)(X,{name:`add`,className:`h-4 w-4`}),t[46]=se):se=t[46];let ce;t[47]!==E||t[48]!==oe?(ce=(0,$.jsx)(J,{"data-settings-item":`skills.create`,size:`icon`,variant:`ghost`,"aria-label":oe,onClick:E,children:se}),t[47]=E,t[48]=oe,t[49]=ce):ce=t[49];let ue;t[50]!==ae||t[51]!==ce?(ue=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[ae,ce]}),t[50]=ae,t[51]=ce,t[52]=ue):ue=t[52];let de=ue,fe;t[53]!==M||t[54]!==n||t[55]!==f||t[56]!==m||t[57]!==h?(fe=e=>(0,$.jsx)(Hl,{skill:e,isSelected:m===e.name,onSelect:()=>{h(e.name),n?.()},onRename:()=>P(e),onDelete:()=>O(e),onDuplicate:()=>M(e),isMenuOpen:f===e.name,onMenuOpenChange:t=>p(t?e.name:null)},e.name),t[53]=M,t[54]=n,t[55]=f,t[56]=m,t[57]=h,t[58]=fe):fe=t[58];let pe=fe,me,he;t[59]===Symbol.for(`react.memo_cache_sentinel`)?(me=q(`oc-settings-page-content h-full overflow-y-auto p-3`,`bg-background`),he=(0,$.jsx)(ja,{}),t[59]=me,t[60]=he):(me=t[59],he=t[60]);let ge;t[61]!==w.length||t[62]!==r?(ge=w.length===0?(0,$.jsx)(vi,{children:(0,$.jsxs)(`div`,{className:`oc-settings-group-row py-12 text-center text-muted-foreground`,children:[(0,$.jsx)(X,{name:`book-open`,className:`mx-auto mb-3 h-10 w-10 opacity-50`}),(0,$.jsx)(`p`,{className:`typography-ui-label font-medium`,children:r(`settings.skills.sidebar.empty.title`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 opacity-75`,children:r(`settings.skills.sidebar.empty.description`)})]})}):null,t[61]=w.length,t[62]=r,t[63]=ge):ge=t[63];let _e;t[64]!==W.ungrouped||t[65]!==de||t[66]!==pe?(_e=W.ungrouped.length>0?(0,$.jsx)(vi,{label:de,children:W.ungrouped.map(pe)}):(0,$.jsx)(vi,{label:de,cardClassName:`hidden`,children:(0,$.jsx)(`span`,{})}),t[64]=W.ungrouped,t[65]=de,t[66]=pe,t[67]=_e):_e=t[67];let ve;if(t[68]!==W.sortedGroups||t[69]!==ne||t[70]!==pe){let e;t[72]!==ne||t[73]!==pe?(e=e=>{let{name:t,skills:n}=e;return(0,$.jsx)(Ra,{label:t,labelPrefix:ne,count:n.length,storageKey:`project-skills`,variant:`settings-card`,children:n.map(pe)},t)},t[72]=ne,t[73]=pe,t[74]=e):e=t[74],ve=W.sortedGroups.map(e),t[68]=W.sortedGroups,t[69]=ne,t[70]=pe,t[71]=ve}else ve=t[71];let K;t[75]!==G.ungrouped||t[76]!==pe||t[77]!==ie?(K=G.ungrouped.length>0?(0,$.jsx)(vi,{label:ie,children:G.ungrouped.map(pe)}):null,t[75]=G.ungrouped,t[76]=pe,t[77]=ie,t[78]=K):K=t[78];let ye;if(t[79]!==G.sortedGroups||t[80]!==pe||t[81]!==ie){let e;t[83]!==pe||t[84]!==ie?(e=e=>{let{name:t,skills:n}=e;return(0,$.jsx)(Ra,{label:t,labelPrefix:ie,count:n.length,storageKey:`user-skills`,variant:`settings-card`,children:n.map(pe)},t)},t[83]=pe,t[84]=ie,t[85]=e):e=t[85],ye=G.sortedGroups.map(e),t[79]=G.sortedGroups,t[80]=pe,t[81]=ie,t[82]=ye}else ye=t[82];let be=c!==null,xe;t[86]===u?xe=t[87]:(xe=e=>{!e&&!u&&l(null)},t[86]=u,t[87]=xe);let Se;t[88]===r?Se=t[89]:(Se=r(`settings.skills.sidebar.deleteDialog.title`),t[88]=r,t[89]=Se);let Ce;t[90]===Se?Ce=t[91]:(Ce=(0,$.jsx)(Xt,{children:Se}),t[90]=Se,t[91]=Ce);let we=c?.name??``,Te;t[92]!==r||t[93]!==we?(Te=r(`settings.skills.sidebar.deleteDialog.description`,{name:we}),t[92]=r,t[93]=we,t[94]=Te):Te=t[94];let Ee;t[95]===Te?Ee=t[96]:(Ee=(0,$.jsx)(Zt,{children:Te}),t[95]=Te,t[96]=Ee);let De;t[97]!==Ce||t[98]!==Ee?(De=(0,$.jsxs)(qt,{children:[Ce,Ee]}),t[97]=Ce,t[98]=Ee,t[99]=De):De=t[99];let Oe;t[100]===Symbol.for(`react.memo_cache_sentinel`)?(Oe=()=>l(null),t[100]=Oe):Oe=t[100];let ke;t[101]===r?ke=t[102]:(ke=r(`settings.common.actions.cancel`),t[101]=r,t[102]=ke);let Ae;t[103]!==u||t[104]!==ke?(Ae=(0,$.jsx)(J,{size:`sm`,className:`text-foreground hover:bg-interactive-hover hover:text-foreground`,variant:`ghost`,onClick:Oe,disabled:u,children:ke}),t[103]=u,t[104]=ke,t[105]=Ae):Ae=t[105];let je;t[106]===r?je=t[107]:(je=r(`settings.common.actions.delete`),t[106]=r,t[107]=je);let Ne;t[108]!==A||t[109]!==u||t[110]!==je?(Ne=(0,$.jsx)(J,{size:`sm`,onClick:A,disabled:u,children:je}),t[108]=A,t[109]=u,t[110]=je,t[111]=Ne):Ne=t[111];let Pe;t[112]!==Ae||t[113]!==Ne?(Pe=(0,$.jsxs)(Jt,{children:[Ae,Ne]}),t[112]=Ae,t[113]=Ne,t[114]=Pe):Pe=t[114];let Fe;t[115]!==De||t[116]!==Pe?(Fe=(0,$.jsxs)(Yt,{className:`max-w-md`,children:[De,Pe]}),t[115]=De,t[116]=Pe,t[117]=Fe):Fe=t[117];let Ie;t[118]!==be||t[119]!==xe||t[120]!==Fe?(Ie=(0,$.jsx)(Qt,{open:be,onOpenChange:xe,children:Fe}),t[118]=be,t[119]=xe,t[120]=Fe,t[121]=Ie):Ie=t[121];let Le=i!==null,Re;t[122]===Symbol.for(`react.memo_cache_sentinel`)?(Re=e=>!e&&a(null),t[122]=Re):Re=t[122];let ze;t[123]===r?ze=t[124]:(ze=r(`settings.skills.sidebar.renameDialog.title`),t[123]=r,t[124]=ze);let Be;t[125]===ze?Be=t[126]:(Be=(0,$.jsx)(Xt,{children:ze}),t[125]=ze,t[126]=Be);let Ve=i?.name??``,He;t[127]!==r||t[128]!==Ve?(He=r(`settings.skills.sidebar.renameDialog.description`,{name:Ve}),t[127]=r,t[128]=Ve,t[129]=He):He=t[129];let Ue;t[130]===He?Ue=t[131]:(Ue=(0,$.jsx)(Zt,{children:He}),t[130]=He,t[131]=Ue);let We;t[132]!==Be||t[133]!==Ue?(We=(0,$.jsxs)(qt,{children:[Be,Ue]}),t[132]=Be,t[133]=Ue,t[134]=We):We=t[134];let Ge;t[135]===Symbol.for(`react.memo_cache_sentinel`)?(Ge=e=>s(e.target.value),t[135]=Ge):Ge=t[135];let Ke;t[136]===r?Ke=t[137]:(Ke=r(`settings.skills.sidebar.renameDialog.placeholder`),t[136]=r,t[137]=Ke);let qe;t[138]===I?qe=t[139]:(qe=e=>{e.key===`Enter`&&I()},t[138]=I,t[139]=qe);let Je;t[140]!==o||t[141]!==Ke||t[142]!==qe?(Je=(0,$.jsx)(fn,{value:o,onChange:Ge,placeholder:Ke,className:`text-foreground placeholder:text-muted-foreground`,onKeyDown:qe}),t[140]=o,t[141]=Ke,t[142]=qe,t[143]=Je):Je=t[143];let Ye;t[144]===Symbol.for(`react.memo_cache_sentinel`)?(Ye=()=>a(null),t[144]=Ye):Ye=t[144];let Xe;t[145]===r?Xe=t[146]:(Xe=r(`settings.common.actions.cancel`),t[145]=r,t[146]=Xe);let Ze;t[147]===Xe?Ze=t[148]:(Ze=(0,$.jsx)(J,{size:`sm`,className:`text-foreground hover:bg-interactive-hover hover:text-foreground`,variant:`ghost`,onClick:Ye,children:Xe}),t[147]=Xe,t[148]=Ze);let Qe;t[149]===r?Qe=t[150]:(Qe=r(`settings.common.actions.rename`),t[149]=r,t[150]=Qe);let $e;t[151]!==I||t[152]!==Qe?($e=(0,$.jsx)(J,{size:`sm`,onClick:I,children:Qe}),t[151]=I,t[152]=Qe,t[153]=$e):$e=t[153];let et;t[154]!==Ze||t[155]!==$e?(et=(0,$.jsxs)(Jt,{children:[Ze,$e]}),t[154]=Ze,t[155]=$e,t[156]=et):et=t[156];let tt;t[157]!==We||t[158]!==Je||t[159]!==et?(tt=(0,$.jsxs)(Yt,{children:[We,Je,et]}),t[157]=We,t[158]=Je,t[159]=et,t[160]=tt):tt=t[160];let nt;t[161]!==Le||t[162]!==tt?(nt=(0,$.jsx)(Qt,{open:Le,onOpenChange:Re,children:tt}),t[161]=Le,t[162]=tt,t[163]=nt):nt=t[163];let rt;return t[164]!==ge||t[165]!==_e||t[166]!==ve||t[167]!==K||t[168]!==ye||t[169]!==Ie||t[170]!==nt?(rt=(0,$.jsxs)(`div`,{className:me,children:[he,ge,_e,ve,K,ye,Ie,nt]}),t[164]=ge,t[165]=_e,t[166]=ve,t[167]=K,t[168]=ye,t[169]=Ie,t[170]=nt,t[171]=rt):rt=t[171],rt},Hl=e=>{let t=(0,Ii.c)(49),{skill:n,isSelected:r,onSelect:i,onDelete:a,onRename:o,onDuplicate:s,isMenuOpen:c,onMenuOpenChange:l}=e,{t:u}=Me(),d;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(d=br(),t[0]=d):d=t[0];let f=d,p;t[1]!==n.source||t[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`),t[1]=n.source,t[2]=u,t[3]=p):p=t[3];let m=p,h;t[4]===n?h=t[5]:(h=Bl(n),t[4]=n,t[5]=h);let g=h,[_,v]=Q.useState(!1),y;t[6]!==a||t[7]!==s||t[8]!==o||t[9]!==u?(y=e=>(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(e,{onClick:e=>{e.stopPropagation(),o()},children:[(0,$.jsx)(X,{name:`edit`,className:`h-4 w-4 mr-px`}),u(`settings.common.actions.rename`)]}),(0,$.jsxs)(e,{onClick:e=>{e.stopPropagation(),s()},children:[(0,$.jsx)(X,{name:`file-copy`,className:`h-4 w-4 mr-px`}),u(`settings.common.actions.duplicate`)]}),(0,$.jsxs)(e,{onClick:e=>{e.stopPropagation(),a()},className:`text-destructive focus:text-destructive`,children:[(0,$.jsx)(X,{name:`delete-bin`,className:`h-4 w-4 mr-px`}),u(`settings.common.actions.delete`)]})]}),t[6]=a,t[7]=s,t[8]=o,t[9]=u,t[10]=y):y=t[10];let b=y,x=!g&&_,S=r?`bg-interactive-selection`:`hover:bg-interactive-hover`,C;t[11]===S?C=t[12]:(C=q(`oc-settings-group-row group relative flex items-center transition-colors duration-150 select-none`,S),t[11]=S,t[12]=C);let w;t[13]===g?w=t[14]:(w=!f&&!g?e=>{e.preventDefault(),v(!0)}:void 0,t[13]=g,t[14]=w);let T;t[15]!==C||t[16]!==w?(T=(0,$.jsx)(`div`,{className:C,onContextMenu:w}),t[15]=C,t[16]=w,t[17]=T):T=t[17];let E;t[18]===n.name?E=t[19]:(E=(0,$.jsx)(`span`,{className:`typography-ui-label font-normal truncate text-foreground`,children:n.name}),t[18]=n.name,t[19]=E);let D;t[20]===n.scope?D=t[21]:(D=(0,$.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}),t[20]=n.scope,t[21]=D);let O;t[22]===m?O=t[23]:(O=(0,$.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:m}),t[22]=m,t[23]=O);let k;t[24]!==E||t[25]!==D||t[26]!==O?(k=(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[E,D,O]}),t[24]=E,t[25]=D,t[26]=O,t[27]=k):k=t[27];let A;t[28]!==i||t[29]!==k?(A=(0,$.jsx)(`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:k}),t[28]=i,t[29]=k,t[30]=A):A=t[30];let j;t[31]!==g||t[32]!==c||t[33]!==l||t[34]!==b?(j=g?null:(0,$.jsxs)(cr,{open:c,onOpenChange:e=>{e&&v(!1),l(e)},children:[(0,$.jsx)(mr,{asChild:!0,children:(0,$.jsx)(J,{size:`sm`,variant:`ghost`,className:`h-6 w-6 px-0 flex-shrink-0 -mr-1 opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100`,children:(0,$.jsx)(X,{name:`more-2`,className:`h-3.5 w-3.5`})})}),(0,$.jsx)(Qn,{align:`end`,className:`w-fit min-w-20`,children:b(Wn)})]}),t[31]=g,t[32]=c,t[33]=l,t[34]=b,t[35]=j):j=t[35];let M;t[36]!==A||t[37]!==j?(M=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center`,children:[A,j]}),t[36]=A,t[37]=j,t[38]=M):M=t[38];let N;t[39]!==M||t[40]!==T?(N=(0,$.jsx)(Ei,{render:T,children:M}),t[39]=M,t[40]=T,t[41]=N):N=t[41];let P;t[42]!==g||t[43]!==b?(P=g?null:(0,$.jsx)(Di,{className:`w-fit min-w-20`,children:b(Oi)}),t[42]=g,t[43]=b,t[44]=P):P=t[44];let F;return t[45]!==N||t[46]!==P||t[47]!==x?(F=(0,$.jsxs)(ki,{open:x,onOpenChange:v,children:[N,P]}),t[45]=N,t[46]=P,t[47]=x,t[48]=F):F=t[48],F};function Ul(e){return{selectedSkillName:e.selectedSkillName,setSelectedSkill:e.setSelectedSkill,setSkillDraft:e.setSkillDraft,createSkill:e.createSkill,deleteSkill:e.deleteSkill,getSkillDetail:e.getSkillDetail}}function Wl(e){return e.scope===`project`}function Gl(e){return e.scope===`user`}function Kl(e,t){return e.localeCompare(t)}function ql(e,t){return e.name.localeCompare(t.name)}function Jl(e,t){return e.name.localeCompare(t.name)}var Yl=()=>{let e=pe.getDirectory();if(typeof e==`string`&&e.trim().length>0)return e;try{let e=window.__zustand_directory_store__;if(e)return e.getState().currentDirectory}catch{}return null},Xl=oe()(ce(e=>({selectedSourceId:mt[0]?.id??null,isScanning:!1,isInstalling:!1,lastScanError:null,lastInstallError:null,scanResults:null,setSelectedSource:t=>e({selectedSourceId:t}),scanRepo:async(t,n)=>{e({isScanning:!0,lastScanError:null,scanResults:null});try{let r=n&&Object.prototype.hasOwnProperty.call(n,`directory`)?typeof n?.directory==`string`&&n.directory.trim()||null:Yl(),i=r?`?directory=${encodeURIComponent(r)}`:``,a=await l(`/api/config/skills/scan${i}`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify(t)}),o=await a.json().catch(()=>null);if(!a.ok||!o){let t=o?.error||{kind:`unknown`,message:`Failed to scan repository`};return e({lastScanError:t}),{ok:!1,error:t}}return o.ok?(e({scanResults:o.items||[]}),o):(e({lastScanError:o.error||{kind:`unknown`,message:`Failed to scan repository`}}),o)}finally{e({isScanning:!1})}},installSkills:async(t,n)=>{let r=n&&Object.prototype.hasOwnProperty.call(n,`directory`)?typeof n?.directory==`string`&&n.directory.trim()||null:Yl(),a=n?.transportIdentity??i();if(i()!==a)return{ok:!1,error:{kind:`unknown`,message:`Failed to install skills`}};e({isInstalling:!0,lastInstallError:null});try{let n=r?`?directory=${encodeURIComponent(r)}`:``,o=await l(`/api/config/skills/install${n}`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify(t)}),s=await o.json().catch(()=>null);if(!s){let t={kind:`unknown`,message:`Failed to install skills`};return e({lastInstallError:t}),{ok:!1,error:t}}if(!o.ok||!s.ok){let t=s.error||{kind:`unknown`,message:`Failed to install skills`};return e({lastInstallError:t}),{ok:!1,error:t}}return i()===a?(await Nt(w,r,a),i()===a&&await at(w,r,a),s):s}catch(t){let n={kind:`unknown`,message:t instanceof Error?t.message:String(t)};return e({lastInstallError:n}),{ok:!1,error:n}}finally{e({isInstalling:!1})}}}),{name:`skills-catalog-store`})),Zl=()=>`custom:${Date.now()}-${Math.random().toString(16).slice(2)}`,Ql=e=>{let t=e.trim(),n=t.startsWith(`https://`)?`https`:t.startsWith(`git@`)?`ssh`:`shorthand`;if(n===`ssh`)return`${t.split(`:`)[1].replace(/\.git$/i,``)}`;if(n===`https`)return t.split(`/`).slice(3).filter(Boolean).join(`/`).replace(/\.git$/i,``);let r=t.match(/^([^/\s]+)\/([^/\s]+)(?:\/.+)?$/);return r?`${r[1]}/${r[2].replace(/\.git$/i,``)}`:t},$l=async()=>{try{let e=L()?.settings;if(e)return(await e.load())?.settings||{};let t=await l(`/api/config/settings`,{method:`GET`,headers:{Accept:`application/json`}});return t.ok?await t.json().catch(()=>null):null}catch{return null}},eu=e=>{let t=(0,Ii.c)(158),{open:n,onOpenChange:r}=e,{t:a}=Me(),o=Xl(tu),s=Xl(nu),c=Xl(ru),l=Mr(iu),u=Mr(au),[d,f]=Q.useState(``),[p,m]=Q.useState(``),[h,g]=Q.useState(``),_;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(_=[],t[0]=_):_=t[0];let[v,y]=Q.useState(_),[b,x]=Q.useState(null),[S,C]=Q.useState(!1),T;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(T=[],t[1]=T):T=t[1];let[E,D]=Q.useState(T),[O,A]=Q.useState(null),j=Q.useRef(0),N=Q.useRef(null),P;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(P=e=>{j.current+=1,C(!1),x(null),N.current=null,e?.clearIdentity&&(D([]),A(null))},t[2]=P):P=t[2];let F=P,I,L;t[3]!==u||t[4]!==n?(I=()=>{n&&(j.current+=1,f(``),m(``),g(``),x(null),C(!1),N.current=null,D([]),A(null),u(),(async()=>{let e=await $l(),t=Array.isArray(e?.skillCatalogs)?e?.skillCatalogs:[];y(t||[])})())},L=[n,u],t[3]=u,t[4]=n,t[5]=I,t[6]=L):(I=t[5],L=t[6]),Q.useEffect(I,L);let R;t[7]===p?R=t[8]:(R=p.trim(),t[7]=p,t[8]=R);let z=R,B;t[9]===h?B=t[10]:(B=h.trim(),t[9]=h,t[10]=B);let V=B,H;if(t[11]!==v||t[12]!==z||t[13]!==V){let e;t[15]!==z||t[16]!==V?(e=e=>{let t=(e.source||``).trim(),n=(e.subpath||``).trim();return t===z&&n===V},t[15]=z,t[16]=V,t[17]=e):e=t[17],H=v.some(e),t[11]=v,t[12]=z,t[13]=V,t[14]=H}else H=t[14];let U=H,W;t[18]!==l||t[19]!==O||t[20]!==d||t[21]!==o||t[22]!==p||t[23]!==h||t[24]!==a?(W=async()=>{let e=p.trim();if(!e){Y.error(a(`settings.skills.catalog.add.toast.repositoryRequired`));return}d.trim()||f(Ql(e)),C(!1),x(null);let t=j.current+1;j.current=t;let n=Gt(),r=i(),s=await o({source:e,subpath:h.trim()||void 0,gitIdentityId:O||void 0},{directory:n});if(j.current!==t||i()!==r||Gt()!==n)return;if(!s.ok){if(s.error?.kind===`authRequired`){if(k()){Y.error(a(`settings.skills.catalog.shared.toast.privateRepoNotSupportedVsCode`));return}let e=s.error.identities||[];if(D(e),!O&&e.length>0){let t=l&&l!==`global`&&e.some(e=>e.id===l)?l:e[0].id;A(t)}Y.error(a(`settings.skills.catalog.add.toast.authenticationRequiredScan`));return}Y.error(s.error?.message||a(`settings.skills.catalog.add.toast.scanFailed`));return}let c=s.items?.length||0;if(x(c),c===0){Y.error(a(`settings.skills.catalog.add.toast.noSkillsFound`)),C(!1);return}D([]),C(!0),N.current={directory:n,transport:r},Y.success(a(`settings.skills.catalog.shared.toast.foundSkills`,{count:c}))},t[18]=l,t[19]=O,t[20]=d,t[21]=o,t[22]=p,t[23]=h,t[24]=a,t[25]=W):W=t[25];let ee=W,G;t[26]!==v||t[27]!==O||t[28]!==U||t[29]!==d||t[30]!==r||t[31]!==S||t[32]!==s||t[33]!==p||t[34]!==h||t[35]!==a?(G=async()=>{let e=d.trim(),t=p.trim(),n=h.trim();if(!e){Y.error(a(`settings.skills.catalog.add.toast.catalogNameRequired`));return}if(!t){Y.error(a(`settings.skills.catalog.add.toast.repositoryRequired`));return}let o=Gt(),c=i();if(!S||N.current?.directory!==o||N.current?.transport!==c){C(!1),N.current=null,Y.error(a(`settings.skills.catalog.add.toast.scanBeforeAdd`));return}if(U){Y.error(a(`settings.skills.catalog.add.toast.catalogAlreadyExists`));return}let l={id:Zl(),label:e,source:t,...n?{subpath:n}:{},...O?{gitIdentityId:O}:{}},u=[...v,l],f=Gt(),m=i();try{await M({skillCatalogs:u}),y(u),Y.success(a(`settings.skills.catalog.add.toast.catalogAdded`)),await w.invalidateQueries({queryKey:[m,`skillsCatalog`,`sources`],exact:!1}),await _t(w,f,m),await lt(w,f,l.id,m),i()===m&&(s(l.id),r(!1))}catch(e){let t=e;Y.error(t instanceof Error?t.message:a(`settings.skills.catalog.add.toast.saveFailed`))}},t[26]=v,t[27]=O,t[28]=U,t[29]=d,t[30]=r,t[31]=S,t[32]=s,t[33]=p,t[34]=h,t[35]=a,t[36]=G):G=t[36];let te=G,ne;t[37]===a?ne=t[38]:(ne=a(`settings.skills.catalog.add.title`),t[37]=a,t[38]=ne);let re;t[39]===ne?re=t[40]:(re=(0,$.jsx)(Xt,{children:ne}),t[39]=ne,t[40]=re);let ie;t[41]===a?ie=t[42]:(ie=a(`settings.skills.catalog.add.descriptionPrefix`),t[41]=a,t[42]=ie);let ae;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(ae=(0,$.jsx)(`code`,{className:`font-mono`,children:`SKILL.md`}),t[43]=ae):ae=t[43];let oe;t[44]===a?oe=t[45]:(oe=a(`settings.skills.catalog.add.descriptionSuffix`),t[44]=a,t[45]=oe);let se;t[46]!==ie||t[47]!==oe?(se=(0,$.jsxs)(Zt,{children:[ie,` `,ae,oe]}),t[46]=ie,t[47]=oe,t[48]=se):se=t[48];let ce;t[49]!==re||t[50]!==se?(ce=(0,$.jsxs)(qt,{children:[re,se]}),t[49]=re,t[50]=se,t[51]=ce):ce=t[51];let le;t[52]===a?le=t[53]:(le=a(`settings.skills.catalog.add.field.catalogName`),t[52]=a,t[53]=le);let ue;t[54]===le?ue=t[55]:(ue=(0,$.jsx)(`label`,{className:`typography-ui-label text-foreground`,children:le}),t[54]=le,t[55]=ue);let de;t[56]===Symbol.for(`react.memo_cache_sentinel`)?(de=e=>f(e.target.value),t[56]=de):de=t[56];let fe;t[57]===a?fe=t[58]:(fe=a(`settings.skills.catalog.add.field.catalogNamePlaceholder`),t[57]=a,t[58]=fe);let pe;t[59]!==d||t[60]!==fe?(pe=(0,$.jsx)(fn,{value:d,onChange:de,placeholder:fe}),t[59]=d,t[60]=fe,t[61]=pe):pe=t[61];let me;t[62]!==ue||t[63]!==pe?(me=(0,$.jsxs)(`div`,{className:`space-y-2`,children:[ue,pe]}),t[62]=ue,t[63]=pe,t[64]=me):me=t[64];let he;t[65]===a?he=t[66]:(he=a(`settings.skills.catalog.add.field.repository`),t[65]=a,t[66]=he);let ge;t[67]===he?ge=t[68]:(ge=(0,$.jsx)(`label`,{className:`typography-ui-label text-foreground`,children:he}),t[67]=he,t[68]=ge);let _e;t[69]===Symbol.for(`react.memo_cache_sentinel`)?(_e=e=>{m(e.target.value),F({clearIdentity:!0})},t[69]=_e):_e=t[69];let ve;t[70]===a?ve=t[71]:(ve=a(`settings.skills.catalog.shared.field.repositoryPlaceholder`),t[70]=a,t[71]=ve);let K;t[72]!==p||t[73]!==ve?(K=(0,$.jsx)(fn,{value:p,onChange:_e,placeholder:ve}),t[72]=p,t[73]=ve,t[74]=K):K=t[74];let ye;t[75]===a?ye=t[76]:(ye=a(`settings.skills.catalog.add.field.repositoryHint`),t[75]=a,t[76]=ye);let be;t[77]===ye?be=t[78]:(be=(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground`,children:ye}),t[77]=ye,t[78]=be);let xe;t[79]!==ge||t[80]!==K||t[81]!==be?(xe=(0,$.jsxs)(`div`,{className:`space-y-2`,children:[ge,K,be]}),t[79]=ge,t[80]=K,t[81]=be,t[82]=xe):xe=t[82];let Se;t[83]===a?Se=t[84]:(Se=a(`settings.skills.catalog.add.field.optionalSubpath`),t[83]=a,t[84]=Se);let Ce;t[85]===Se?Ce=t[86]:(Ce=(0,$.jsx)(`label`,{className:`typography-ui-label text-foreground`,children:Se}),t[85]=Se,t[86]=Ce);let we;t[87]===Symbol.for(`react.memo_cache_sentinel`)?(we=e=>{g(e.target.value),F({clearIdentity:!0})},t[87]=we):we=t[87];let Te;t[88]===a?Te=t[89]:(Te=a(`settings.skills.catalog.shared.field.subpathPlaceholder`),t[88]=a,t[89]=Te);let Ee;t[90]!==h||t[91]!==Te?(Ee=(0,$.jsx)(fn,{value:h,onChange:we,placeholder:Te}),t[90]=h,t[91]=Te,t[92]=Ee):Ee=t[92];let De;t[93]!==Ce||t[94]!==Ee?(De=(0,$.jsxs)(`div`,{className:`space-y-2`,children:[Ce,Ee]}),t[93]=Ce,t[94]=Ee,t[95]=De):De=t[95];let Oe;t[96]!==O||t[97]!==E||t[98]!==a?(Oe=E.length>0&&!k()?(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-[var(--status-warning)]`,children:a(`settings.skills.catalog.shared.auth.title`)}),(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground ml-2`,children:a(`settings.skills.catalog.shared.auth.description`)})]}),(0,$.jsxs)(ln,{value:O||``,onValueChange:e=>{A(e),F()},children:[(0,$.jsx)(rn,{className:`w-fit`,children:(0,$.jsx)(`span`,{children:E.find(e=>e.id===O)?.name||a(`settings.skills.catalog.shared.auth.chooseIdentity`)})}),(0,$.jsx)(an,{align:`start`,children:E.map(ou)})]}),(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground`,children:a(`settings.skills.catalog.shared.auth.footerHint`)})]}):null,t[96]=O,t[97]=E,t[98]=a,t[99]=Oe):Oe=t[99];let ke;t[100]!==b||t[101]!==a?(ke=b===null?null:(0,$.jsx)(`div`,{className:`typography-meta text-muted-foreground`,children:a(`settings.skills.catalog.add.scanResult`,{count:b})}),t[100]=b,t[101]=a,t[102]=ke):ke=t[102];let Ae;t[103]!==U||t[104]!==a?(Ae=U?(0,$.jsx)(`div`,{className:`typography-meta text-muted-foreground`,children:a(`settings.skills.catalog.add.duplicateMessage`)}):null,t[103]=U,t[104]=a,t[105]=Ae):Ae=t[105];let je;t[106]!==me||t[107]!==xe||t[108]!==De||t[109]!==Oe||t[110]!==ke||t[111]!==Ae?(je=(0,$.jsxs)(`div`,{className:`space-y-4`,children:[me,xe,De,Oe,ke,Ae]}),t[106]=me,t[107]=xe,t[108]=De,t[109]=Oe,t[110]=ke,t[111]=Ae,t[112]=je):je=t[112];let Ne;t[113]===r?Ne=t[114]:(Ne=()=>r(!1),t[113]=r,t[114]=Ne);let Pe;t[115]===a?Pe=t[116]:(Pe=a(`settings.common.actions.cancel`),t[115]=a,t[116]=Pe);let q;t[117]!==Ne||t[118]!==Pe?(q=(0,$.jsx)(J,{size:`sm`,variant:`ghost`,onClick:Ne,children:Pe}),t[117]=Ne,t[118]=Pe,t[119]=q):q=t[119];let Fe;t[120]===ee?Fe=t[121]:(Fe=()=>void ee(),t[120]=ee,t[121]=Fe);let Ie;t[122]!==c||t[123]!==p?(Ie=c||!p.trim(),t[122]=c,t[123]=p,t[124]=Ie):Ie=t[124];let Le;t[125]===Symbol.for(`react.memo_cache_sentinel`)?(Le=(0,$.jsx)(X,{name:`git-repository`,className:`h-4 w-4`}),t[125]=Le):Le=t[125];let Re;t[126]!==c||t[127]!==a?(Re=a(c?`settings.skills.catalog.shared.actions.scanning`:`settings.skills.catalog.shared.actions.scan`),t[126]=c,t[127]=a,t[128]=Re):Re=t[128];let ze;t[129]!==Fe||t[130]!==Ie||t[131]!==Re?(ze=(0,$.jsxs)(J,{size:`sm`,className:`gap-2`,variant:`ghost`,onClick:Fe,disabled:Ie,children:[Le,Re]}),t[129]=Fe,t[130]=Ie,t[131]=Re,t[132]=ze):ze=t[132];let Be;t[133]===te?Be=t[134]:(Be=()=>void te(),t[133]=te,t[134]=Be);let Ve;t[135]!==U||t[136]!==d||t[137]!==S||t[138]!==p?(Ve=!S||U||!d.trim()||!p.trim(),t[135]=U,t[136]=d,t[137]=S,t[138]=p,t[139]=Ve):Ve=t[139];let He;t[140]===a?He=t[141]:(He=a(`settings.skills.catalog.add.actions.addCatalog`),t[140]=a,t[141]=He);let Ue;t[142]!==Be||t[143]!==Ve||t[144]!==He?(Ue=(0,$.jsx)(J,{size:`sm`,onClick:Be,disabled:Ve,children:He}),t[142]=Be,t[143]=Ve,t[144]=He,t[145]=Ue):Ue=t[145];let We;t[146]!==q||t[147]!==ze||t[148]!==Ue?(We=(0,$.jsxs)(Jt,{children:[q,ze,Ue]}),t[146]=q,t[147]=ze,t[148]=Ue,t[149]=We):We=t[149];let Ge;t[150]!==ce||t[151]!==je||t[152]!==We?(Ge=(0,$.jsxs)(Yt,{className:`max-w-xl`,children:[ce,je,We]}),t[150]=ce,t[151]=je,t[152]=We,t[153]=Ge):Ge=t[153];let Ke;return t[154]!==r||t[155]!==n||t[156]!==Ge?(Ke=(0,$.jsx)(Qt,{open:n,onOpenChange:r,children:Ge}),t[154]=r,t[155]=n,t[156]=Ge,t[157]=Ke):Ke=t[157],Ke};function tu(e){return e.scanRepo}function nu(e){return e.setSelectedSource}function ru(e){return e.isScanning}function iu(e){return e.defaultGitIdentityId}function au(e){return e.loadDefaultGitIdentityId}function ou(e){return(0,$.jsx)(tn,{value:e.id,children:e.name},e.id)}var su=e=>{let t=(0,Ii.c)(85),{open:n,onOpenChange:r,conflicts:i,onConfirm:a}=e,{t:o}=Me(),s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s={},t[0]=s):s=t[0];let[c,l]=Q.useState(s),u,d;t[1]!==i||t[2]!==n?(u=()=>{if(!n)return;let e={};for(let t of i)e[t.skillName]=`skip`;l(e)},d=[n,i],t[1]=i,t[2]=n,t[3]=u,t[4]=d):(u=t[3],d=t[4]),Q.useEffect(u,d);let f;t[5]===i?f=t[6]:(f=e=>{let t={};for(let n of i)t[n.skillName]=e;l(t)},t[5]=i,t[6]=f);let p=f,m;t[7]!==i||t[8]!==c?(m=i.length>0&&i.every(e=>c[e.skillName]),t[7]=i,t[8]=c,t[9]=m):m=t[9];let h=m,g;t[10]===o?g=t[11]:(g=o(`settings.skills.catalog.conflicts.title`),t[10]=o,t[11]=g);let _;t[12]===g?_=t[13]:(_=(0,$.jsx)(Xt,{children:g}),t[12]=g,t[13]=_);let v;t[14]===o?v=t[15]:(v=o(`settings.skills.catalog.conflicts.description`),t[14]=o,t[15]=v);let y;t[16]===v?y=t[17]:(y=(0,$.jsx)(Zt,{children:v}),t[16]=v,t[17]=y);let b;t[18]!==_||t[19]!==y?(b=(0,$.jsxs)(qt,{children:[_,y]}),t[18]=_,t[19]=y,t[20]=b):b=t[20];let x;t[21]!==i.length||t[22]!==o?(x=o(`settings.skills.catalog.conflicts.count`,{count:i.length}),t[21]=i.length,t[22]=o,t[23]=x):x=t[23];let S;t[24]===x?S=t[25]:(S=(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:x}),t[24]=x,t[25]=S);let C;t[26]===p?C=t[27]:(C=()=>p(`skip`),t[26]=p,t[27]=C);let w;t[28]===o?w=t[29]:(w=o(`settings.skills.catalog.conflicts.actions.skipAll`),t[28]=o,t[29]=w);let T;t[30]!==C||t[31]!==w?(T=(0,$.jsx)(J,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:C,children:w}),t[30]=C,t[31]=w,t[32]=T):T=t[32];let E;t[33]===p?E=t[34]:(E=()=>p(`overwrite`),t[33]=p,t[34]=E);let D;t[35]===o?D=t[36]:(D=o(`settings.skills.catalog.conflicts.actions.overwriteAll`),t[35]=o,t[36]=D);let O;t[37]!==E||t[38]!==D?(O=(0,$.jsx)(J,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:E,children:D}),t[37]=E,t[38]=D,t[39]=O):O=t[39];let k;t[40]!==T||t[41]!==O?(k=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[T,O]}),t[40]=T,t[41]=O,t[42]=k):k=t[42];let A;t[43]!==S||t[44]!==k?(A=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[S,k]}),t[43]=S,t[44]=k,t[45]=A):A=t[45];let j;if(t[46]!==i||t[47]!==c||t[48]!==o){let e;t[50]!==c||t[51]!==o?(e=e=>(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 py-1.5`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`div`,{className:`typography-ui-label truncate`,children:e.skillName}),(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground`,children:o(`settings.skills.catalog.conflicts.installedIn`,{scope:e.scope===`project`?o(`settings.skills.catalog.conflicts.scope.project`):o(`settings.skills.catalog.conflicts.scope.user`),source:e.source===`agents`?o(`settings.skills.catalog.conflicts.source.agents`):o(`settings.skills.catalog.conflicts.source.opencode`)})})]}),(0,$.jsxs)(ln,{value:c[e.skillName]||`skip`,onValueChange:t=>l(n=>({...n,[e.skillName]:t})),children:[(0,$.jsx)(rn,{className:`w-fit`,children:(0,$.jsx)(`span`,{className:`capitalize`,children:(c[e.skillName]||`skip`)===`overwrite`?o(`settings.skills.catalog.conflicts.decision.overwrite`):o(`settings.skills.catalog.conflicts.decision.skip`)})}),(0,$.jsxs)(an,{align:`end`,children:[(0,$.jsx)(tn,{value:`skip`,className:`pr-2 [&>span:first-child]:hidden`,children:o(`settings.skills.catalog.conflicts.decision.skip`)}),(0,$.jsx)(tn,{value:`overwrite`,className:`pr-2 [&>span:first-child]:hidden`,children:o(`settings.skills.catalog.conflicts.decision.overwrite`)})]})]})]},e.skillName),t[50]=c,t[51]=o,t[52]=e):e=t[52],j=i.map(e),t[46]=i,t[47]=c,t[48]=o,t[49]=j}else j=t[49];let M;t[53]===j?M=t[54]:(M=(0,$.jsx)(`div`,{className:`space-y-2`,children:j}),t[53]=j,t[54]=M);let N;t[55]!==A||t[56]!==M?(N=(0,$.jsxs)(`div`,{className:`space-y-3`,children:[A,M]}),t[55]=A,t[56]=M,t[57]=N):N=t[57];let P;t[58]===r?P=t[59]:(P=()=>r(!1),t[58]=r,t[59]=P);let F;t[60]===o?F=t[61]:(F=o(`settings.common.actions.cancel`),t[60]=o,t[61]=F);let I;t[62]!==P||t[63]!==F?(I=(0,$.jsx)(J,{size:`sm`,variant:`ghost`,onClick:P,children:F}),t[62]=P,t[63]=F,t[64]=I):I=t[64];let L;t[65]!==c||t[66]!==a?(L=()=>a(c),t[65]=c,t[66]=a,t[67]=L):L=t[67];let R=!h,z;t[68]===o?z=t[69]:(z=o(`settings.skills.catalog.conflicts.actions.continue`),t[68]=o,t[69]=z);let B;t[70]!==L||t[71]!==R||t[72]!==z?(B=(0,$.jsx)(J,{size:`sm`,onClick:L,disabled:R,children:z}),t[70]=L,t[71]=R,t[72]=z,t[73]=B):B=t[73];let V;t[74]!==I||t[75]!==B?(V=(0,$.jsxs)(Jt,{children:[I,B]}),t[74]=I,t[75]=B,t[76]=V):V=t[76];let H;t[77]!==b||t[78]!==N||t[79]!==V?(H=(0,$.jsxs)(Yt,{className:`max-w-2xl`,children:[b,N,V]}),t[77]=b,t[78]=N,t[79]=V,t[80]=H):H=t[80];let U;return t[81]!==r||t[82]!==n||t[83]!==H?(U=(0,$.jsx)(Qt,{open:n,onOpenChange:r,children:H}),t[81]=r,t[82]=n,t[83]=H,t[84]=U):U=t[84],U},cu=[{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 lu(e,t){return e===`project`&&t===`claude`?`project-claude`:e===`project`&&t===`agents`?`project-agents`:t===`claude`?`user-claude`:e===`project`?`project-opencode`:t===`agents`?`user-agents`:`user-opencode`}function uu(e){if(e===`user-claude`)return{scope:`user`,source:`claude`};if(e===`project-claude`)return{scope:`project`,source:`claude`};let t=cu.find(t=>t.value===e);return t?{scope:t.scope,source:t.source}:{scope:`user`,source:`opencode`}}var du=e=>{let t=(0,Ii.c)(124),{open:n,onOpenChange:r,item:a}=e,{t:o}=Me(),s=Xl(fu),c=Xl(pu),[l,u]=Q.useState(`user`),[d,f]=Q.useState(`opencode`),p=Ct(mu),m=Ct(hu),[h,g]=Q.useState(null),[_,v]=Q.useState(!1),y;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(y=[],t[0]=y):y=t[0];let[b,x]=Q.useState(y),[S,C]=Q.useState(null),w,T;t[1]!==m||t[2]!==n?(w=()=>{n&&(u(`user`),f(`opencode`),g(m),v(!1),x([]),C(null))},T=[n,m],t[1]=m,t[2]=n,t[3]=w,t[4]=T):(w=t[3],T=t[4]),Q.useEffect(w,T);let E;t[5]===o?E=t[6]:(E=e=>{switch(e){case`project-opencode`:return o(`settings.skills.location.option.projectOpencode.label`);case`user-agents`:return o(`settings.skills.location.option.userAgents.label`);case`project-agents`:return o(`settings.skills.location.option.projectAgents.label`);default:return o(`settings.skills.location.option.userOpencode.label`)}},t[5]=o,t[6]=E);let D=E,O;t[7]===o?O=t[8]:(O=e=>{switch(e){case`project-opencode`:return o(`settings.skills.location.option.projectOpencode.description`);case`user-agents`:return o(`settings.skills.location.option.userAgents.description`);case`project-agents`:return o(`settings.skills.location.option.projectAgents.description`);default:return o(`settings.skills.location.option.userOpencode.description`)}},t[7]=o,t[8]=O);let k=O,A;bb0:{if(p.length===0){A=null;break bb0}if(h&&p.some(e=>e.id===h)){A=h;break bb0}if(m&&p.some(e=>e.id===m)){A=m;break bb0}A=p[0]?.id??null}let j=A,M;bb1:{if(l!==`project`){M=null;break bb1}let e=j;if(!e){M=null;break bb1}let n;if(t[9]!==e||t[10]!==p){let r;t[12]===e?r=t[13]:(r=t=>t.id===e,t[12]=e,t[13]=r),n=p.find(r),t[9]=e,t[10]=p,t[11]=n}else n=t[11];M=n?.path??null}let N=M,P;t[14]!==s||t[15]!==a||t[16]!==r||t[17]!==o?(P=async e=>{let t={skillDir:e.skillDir};a?.clawdhub&&(t.clawdhub={slug:a.clawdhub.slug,version:a.clawdhub.version});let n=await s({source:e.source,subpath:e.subpath,gitIdentityId:a?.gitIdentityId,scope:e.scope,targetSource:e.targetSource,selections:[t],conflictPolicy:`prompt`,conflictDecisions:e.conflictDecisions},{directory:e.effectiveDirectory,transportIdentity:e.transportIdentity});if(n.ok){Y.success(o(`settings.skills.catalog.installSkill.toast.installed`)),r(!1);return}if(n.error?.kind===`conflicts`){C({source:e.source,subpath:e.subpath,scope:e.scope,targetSource:e.targetSource,skillDir:e.skillDir,directoryOverride:e.directoryOverride??null,effectiveDirectory:e.effectiveDirectory,transportIdentity:e.transportIdentity}),x(n.error.conflicts),v(!0);return}if(n.error?.kind===`authRequired`){Y.error(n.error.message||o(`settings.skills.catalog.installSkill.toast.authRequired`));return}Y.error(n.error?.message||o(`settings.skills.catalog.installSkill.toast.installFailed`))},t[14]=s,t[15]=a,t[16]=r,t[17]=o,t[18]=P):P=t[18];let F=P;if(!a)return null;let I;t[19]===o?I=t[20]:(I=o(`settings.skills.catalog.installSkill.title`),t[19]=o,t[20]=I);let L;t[21]===I?L=t[22]:(L=(0,$.jsx)(Xt,{children:I}),t[21]=I,t[22]=L);let R;t[23]===o?R=t[24]:(R=o(`settings.skills.catalog.installSkill.descriptionPrefix`),t[23]=o,t[24]=R);let z;t[25]===a.skillName?z=t[26]:(z=(0,$.jsx)(`span`,{className:`font-semibold text-foreground`,children:a.skillName}),t[25]=a.skillName,t[26]=z);let B;t[27]===o?B=t[28]:(B=o(`settings.skills.catalog.installSkill.descriptionSuffix`),t[27]=o,t[28]=B);let V;t[29]!==R||t[30]!==z||t[31]!==B?(V=(0,$.jsxs)(Zt,{children:[R,` `,z,` `,B]}),t[29]=R,t[30]=z,t[31]=B,t[32]=V):V=t[32];let H;t[33]!==L||t[34]!==V?(H=(0,$.jsxs)(qt,{children:[L,V]}),t[33]=L,t[34]=V,t[35]=H):H=t[35];let U;t[36]===o?U=t[37]:(U=o(`settings.skills.catalog.installSkill.field.destination`),t[36]=o,t[37]=U);let W;t[38]===U?W=t[39]:(W=(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:U}),t[38]=U,t[39]=W);let ee;t[40]!==l||t[41]!==d?(ee=lu(l,d),t[40]=l,t[41]=d,t[42]=ee):ee=t[42];let G;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(G=e=>{let t=uu(e);u(t.scope),f(t.source===`agents`?`agents`:`opencode`)},t[43]=G):G=t[43];let te;t[44]===l?te=t[45]:(te=l===`user`?(0,$.jsx)(X,{name:`user-3`,className:`h-3.5 w-3.5`}):(0,$.jsx)(X,{name:`folder`,className:`h-3.5 w-3.5`}),t[44]=l,t[45]=te);let ne;t[46]===d?ne=t[47]:(ne=d===`agents`?(0,$.jsx)(X,{name:`robot-2`,className:`h-3.5 w-3.5`}):null,t[46]=d,t[47]=ne);let re;t[48]!==D||t[49]!==l||t[50]!==d?(re=D(lu(l,d)),t[48]=D,t[49]=l,t[50]=d,t[51]=re):re=t[51];let ie;t[52]===re?ie=t[53]:(ie=(0,$.jsx)(`span`,{children:re}),t[52]=re,t[53]=ie);let ae;t[54]!==te||t[55]!==ne||t[56]!==ie?(ae=(0,$.jsxs)(rn,{className:`w-fit gap-1.5`,children:[te,ne,ie]}),t[54]=te,t[55]=ne,t[56]=ie,t[57]=ae):ae=t[57];let oe;t[58]!==k||t[59]!==D?(oe=cu.map(e=>(0,$.jsx)(tn,{value:e.value,className:`pr-2 [&>span:first-child]:hidden`,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.scope===`user`?(0,$.jsx)(X,{name:`user-3`,className:`h-3.5 w-3.5`}):(0,$.jsx)(X,{name:`folder`,className:`h-3.5 w-3.5`}),e.source===`agents`?(0,$.jsx)(X,{name:`robot-2`,className:`h-3.5 w-3.5`}):null,(0,$.jsx)(`span`,{children:D(e.value)})]}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground ml-5`,children:k(e.value)})]})},e.value)),t[58]=k,t[59]=D,t[60]=oe):oe=t[60];let se;t[61]===oe?se=t[62]:(se=(0,$.jsx)(an,{align:`start`,children:oe}),t[61]=oe,t[62]=se);let ce;t[63]!==ee||t[64]!==ae||t[65]!==se?(ce=(0,$.jsxs)(ln,{value:ee,onValueChange:G,children:[ae,se]}),t[63]=ee,t[64]=ae,t[65]=se,t[66]=ce):ce=t[66];let le;t[67]!==W||t[68]!==ce?(le=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[W,ce]}),t[67]=W,t[68]=ce,t[69]=le):le=t[69];let ue;t[70]!==p||t[71]!==j||t[72]!==l||t[73]!==o?(ue=l===`project`&&(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:o(`settings.skills.catalog.installSkill.field.project`)}),p.length===0?(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:o(`settings.skills.catalog.installSkill.field.noProjects`)}):(0,$.jsxs)(ln,{value:j??``,onValueChange:e=>g(e),disabled:p.length===1,children:[(0,$.jsx)(rn,{className:`w-fit`,children:(0,$.jsx)(dn,{placeholder:o(`settings.skills.catalog.installSkill.field.chooseProjectPlaceholder`)})}),(0,$.jsx)(an,{align:`start`,children:p.map(gu)})]})]}),t[70]=p,t[71]=j,t[72]=l,t[73]=o,t[74]=ue):ue=t[74];let de;t[75]===a.warnings?de=t[76]:(de=a.warnings?.length?(0,$.jsx)(`div`,{className:`typography-micro text-[var(--status-warning)] bg-[var(--status-warning)]/10 px-2 py-1.5 rounded`,children:a.warnings.join(` · `)}):null,t[75]=a.warnings,t[76]=de);let fe;t[77]!==le||t[78]!==ue||t[79]!==de?(fe=(0,$.jsxs)(`div`,{className:`mt-2 space-y-3`,children:[le,ue,de]}),t[77]=le,t[78]=ue,t[79]=de,t[80]=fe):fe=t[80];let pe;t[81]===r?pe=t[82]:(pe=()=>r(!1),t[81]=r,t[82]=pe);let me;t[83]===o?me=t[84]:(me=o(`settings.common.actions.cancel`),t[83]=o,t[84]=me);let he;t[85]!==pe||t[86]!==me?(he=(0,$.jsx)(J,{size:`sm`,variant:`ghost`,onClick:pe,children:me}),t[85]=pe,t[86]=me,t[87]=he):he=t[87];let ge=c||!a.installable||l===`project`&&!N,_e;t[88]!==N||t[89]!==F||t[90]!==a.repoSource||t[91]!==a.repoSubpath||t[92]!==a.skillDir||t[93]!==l||t[94]!==d?(_e=()=>void F({source:a.repoSource,subpath:a.repoSubpath,scope:l,targetSource:d,skillDir:a.skillDir,directoryOverride:N,effectiveDirectory:N??Gt(),transportIdentity:i()}),t[88]=N,t[89]=F,t[90]=a.repoSource,t[91]=a.repoSubpath,t[92]=a.skillDir,t[93]=l,t[94]=d,t[95]=_e):_e=t[95];let ve;t[96]!==c||t[97]!==o?(ve=o(c?`settings.skills.catalog.installSkill.actions.installing`:`settings.skills.catalog.installSkill.actions.install`),t[96]=c,t[97]=o,t[98]=ve):ve=t[98];let K;t[99]!==ge||t[100]!==_e||t[101]!==ve?(K=(0,$.jsx)(J,{size:`sm`,disabled:ge,onClick:_e,children:ve}),t[99]=ge,t[100]=_e,t[101]=ve,t[102]=K):K=t[102];let ye;t[103]!==he||t[104]!==K?(ye=(0,$.jsxs)(Jt,{children:[he,K]}),t[103]=he,t[104]=K,t[105]=ye):ye=t[105];let be;t[106]!==H||t[107]!==fe||t[108]!==ye?(be=(0,$.jsxs)(Yt,{className:`max-w-md`,children:[H,fe,ye]}),t[106]=H,t[107]=fe,t[108]=ye,t[109]=be):be=t[109];let xe;t[110]!==r||t[111]!==n||t[112]!==be?(xe=(0,$.jsx)(Qt,{open:n,onOpenChange:r,children:be}),t[110]=r,t[111]=n,t[112]=be,t[113]=xe):xe=t[113];let Se;t[114]!==S||t[115]!==F?(Se=e=>{S&&(F({source:S.source,subpath:S.subpath,scope:S.scope,targetSource:S.targetSource,skillDir:S.skillDir,conflictDecisions:e,directoryOverride:S.directoryOverride??null,effectiveDirectory:S.effectiveDirectory,transportIdentity:S.transportIdentity}),v(!1))},t[114]=S,t[115]=F,t[116]=Se):Se=t[116];let Ce;t[117]!==b||t[118]!==_||t[119]!==Se?(Ce=(0,$.jsx)(su,{open:_,onOpenChange:v,conflicts:b,onConfirm:Se}),t[117]=b,t[118]=_,t[119]=Se,t[120]=Ce):Ce=t[120];let we;return t[121]!==xe||t[122]!==Ce?(we=(0,$.jsxs)($.Fragment,{children:[xe,Ce]}),t[121]=xe,t[122]=Ce,t[123]=we):we=t[123],we};function fu(e){return e.installSkills}function pu(e){return e.isInstalling}function mu(e){return e.projects}function hu(e){return e.activeProjectId}function gu(e){return(0,$.jsx)(tn,{value:e.id,children:e.label||e.path},e.id)}var _u=async()=>{try{let e=L()?.settings;if(e)return(await e.load())?.settings||{};let t=await l(`/api/config/settings`,{method:`GET`,headers:{Accept:`application/json`}});return t.ok?await t.json().catch(()=>null):null}catch{return null}},vu=({mode:e,onModeChange:t,showModeTabs:n=!0})=>{let{t:r}=Me(),{selectedSourceId:a,setSelectedSource:o}=Xl(le(e=>({selectedSourceId:e.selectedSourceId,setSelectedSource:e.setSelectedSource}))),s=xt(),c=s.data??mt,l=c.some(e=>e.id===a)?a:null,u=$e(l??``,{enabled:!!l}),[d,f]=Q.useState(``),[p,m]=Q.useState(!1),[h,g]=Q.useState(!1),[_,v]=Q.useState(null),[y,b]=Q.useState(!1),[x,S]=Q.useState(!1),[C,T]=Q.useState(!1),[E,D]=Q.useState(null);Q.useEffect(()=>{!s.data&&s.isFetching||c.some(e=>e.id===a)||o(c[0]?.id??null)},[a,o,c,s.data,s.isFetching]);let O=Gt(),k=i();Q.useEffect(()=>{D(null)},[l,O,k]);let A=Q.useMemo(()=>nt(u.data?.pages??[]),[u.data]),j=Q.useMemo(()=>{let e=d.trim().toLowerCase();return e?A.filter(t=>{let n=t.skillName.toLowerCase(),r=(t.description||``).toLowerCase(),i=(t.frontmatterName||``).toLowerCase();return n.includes(e)||r.includes(e)||i.includes(e)}):A},[A,d]),N=Q.useMemo(()=>c.find(e=>e.id===l)||null,[c,l]),P=!!(l&&l.startsWith(`custom:`)),F=N?.source===`clawdhub:registry`||N?.sourceType===`clawdhub`,I=s.isLoading&&!s.data,L=u.isLoading&&!u.data,R=u.isFetchingNextPage,z=E??s.error??u.error,B=async()=>{if(!l||!P)return;let e=Gt(),t=i();b(!0),D(null);try{let n=await _u(),r=(Array.isArray(n?.skillCatalogs)?n?.skillCatalogs:[]).filter(e=>e.id!==l);await M({skillCatalogs:r}),w.setQueriesData({queryKey:[t,`skillsCatalog`,`sources`],exact:!1},e=>e?.filter(e=>e.id!==l)),w.removeQueries({queryKey:[t,`skillsCatalog`,`source`],exact:!1,predicate:e=>e.queryKey[4]===l}),i()===t&&(o(null),S(!1)),await _t(w,e,t)}catch(n){i()===t&&Gt()===e&&D(n instanceof Error?n:Error(String(n)))}finally{b(!1)}},V=async()=>{let e=Gt(),t=i(),n=l;T(!0),D(null);try{n?await lt(w,e,n,t):await _t(w,e,t)}catch(r){let a=Xl.getState().selectedSourceId;i()===t&&Gt()===e&&a===n&&D(r instanceof Error?r:Error(String(r)))}finally{T(!1)}};return(0,$.jsx)(Sr,{outerClassName:`h-full`,className:`w-full`,children:(0,$.jsxs)(`div`,{className:`oc-settings-page-content mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8`,children:[n&&(0,$.jsx)(`div`,{className:`h-10`,children:(0,$.jsx)(jr,{items:[{id:`manual`,label:r(`settings.skills.catalog.page.mode.manual`)},{id:`external`,label:r(`settings.skills.catalog.page.mode.external`)}],activeId:e,onSelect:e=>t(e),layoutMode:`fit`,variant:`animated`,animateActivePill:!1,className:`h-full`})}),(0,$.jsx)(`div`,{"data-settings-item":`skills.catalog.source`,children:(0,$.jsx)(vi,{label:r(`settings.skills.catalog.page.section.sourceRepository`),cardClassName:`p-3`,children:(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 py-1.5`,children:[(0,$.jsxs)(ln,{value:l||``,onValueChange:e=>o(e),children:[(0,$.jsx)(rn,{className:`w-fit`,children:(0,$.jsx)(dn,{placeholder:r(`settings.skills.catalog.page.field.selectSourcePlaceholder`),children:N?.label})}),(0,$.jsx)(an,{align:`start`,children:c.map(e=>(0,$.jsx)(tn,{value:e.id,children:e.label},e.id))})]}),(0,$.jsx)(J,{variant:`outline`,size:`xs`,className:`!font-normal h-6 w-6 px-0`,onClick:()=>void V(),disabled:C,title:r(`settings.skills.catalog.page.actions.refreshTitle`),children:(0,$.jsx)(X,{name:`refresh`,className:q(`h-3.5 w-3.5`,C&&`animate-spin`)})}),P&&(0,$.jsx)(J,{variant:`ghost`,size:`xs`,className:`!font-normal h-6 w-6 px-0 text-[var(--status-error)] hover:text-[var(--status-error)]`,onClick:()=>S(!0),disabled:y,title:r(`settings.skills.catalog.page.actions.removeCatalogTitle`),children:(0,$.jsx)(X,{name:`delete-bin`,className:`h-3.5 w-3.5`})}),(0,$.jsxs)(J,{"data-settings-item":`skills.catalog.add-catalog`,size:`xs`,className:`!font-normal gap-1`,onClick:()=>m(!0),children:[(0,$.jsx)(X,{name:`add`,className:`h-3.5 w-3.5`}),` `,r(`settings.skills.catalog.page.actions.addCatalog`)]})]}),(0,$.jsxs)(`div`,{"data-settings-item":`skills.catalog.search`,children:[(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(X,{name:`search`,className:`absolute left-2 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground`}),(0,$.jsx)(fn,{value:d,onChange:e=>f(e.target.value),placeholder:r(`settings.skills.catalog.shared.field.searchSkillsPlaceholder`),className:`h-7 pl-8 w-full sm:w-64`})]}),(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground mt-1 block`,children:I?r(`settings.skills.catalog.page.loading.catalog`):r(`settings.skills.catalog.page.foundCount`,{count:j.length})})]})]})})}),z&&(0,$.jsxs)(`div`,{className:`rounded-lg border border-[var(--status-error-border)] bg-[var(--status-error-background)] px-4 py-3`,children:[(0,$.jsx)(`div`,{className:`typography-ui-label font-medium text-[var(--status-error)]`,children:r(`settings.skills.catalog.page.error.catalogTitle`)}),(0,$.jsx)(`div`,{className:`typography-meta text-[var(--status-error)]/80 mt-1`,children:z.message})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{children:j.length===0&&!L?(0,$.jsxs)(`div`,{className:`py-8 text-center text-muted-foreground`,children:[(0,$.jsx)(`p`,{className:`typography-body`,children:r(`settings.skills.catalog.page.empty.noSkillsTitle`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 opacity-75`,children:r(`settings.skills.catalog.page.empty.noSkillsDescription`)})]}):L?(0,$.jsxs)(`div`,{className:`py-8 text-center text-muted-foreground`,children:[(0,$.jsx)(X,{name:`refresh`,className:`mx-auto mb-3 h-5 w-5 animate-spin opacity-50`}),(0,$.jsx)(`p`,{className:`typography-meta`,children:r(`settings.skills.catalog.page.loading.skills`)})]}):(0,$.jsx)(`div`,{className:`divide-y divide-[var(--surface-subtle)]`,children:j.map(e=>{let t=e.installed?.isInstalled,n=e.installed?.scope;return(0,$.jsx)(`div`,{className:`py-2`,children:(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label font-medium text-foreground truncate`,children:e.skillName}),t&&(0,$.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:r(`settings.skills.catalog.page.badge.installed`,{scope:n||r(`settings.skills.catalog.page.badge.unknown`)})}),!e.installable&&(0,$.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:r(`settings.skills.catalog.page.badge.notInstallable`)})]}),e.description?(0,$.jsx)(`div`,{className:`typography-meta text-muted-foreground mt-0.5 line-clamp-2`,children:e.description}):(0,$.jsx)(`div`,{className:`typography-meta text-muted-foreground/50 mt-0.5 italic`,children:r(`settings.skills.catalog.shared.noDescription`)}),e.clawdhub&&(0,$.jsxs)(`div`,{className:`typography-micro text-muted-foreground mt-1.5 flex items-center gap-3`,children:[e.clawdhub.owner&&(0,$.jsxs)(`span`,{children:[r(`settings.skills.catalog.page.byOwnerPrefix`),` `,(0,$.jsx)(`span`,{className:`font-medium text-foreground/80`,children:e.clawdhub.owner})]}),(0,$.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(X,{name:`download`,className:`h-3 w-3`}),e.clawdhub.downloads?.toLocaleString()??0]}),(e.clawdhub.stars??0)>0&&(0,$.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(X,{name:`star`,className:`h-3 w-3`}),e.clawdhub.stars]}),(0,$.jsxs)(`span`,{className:`bg-[var(--surface-muted)] px-1.5 py-0.5 rounded`,children:[`v`,e.clawdhub.version]})]}),e.warnings?.length?(0,$.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:e.warnings.join(` · `)}):null]}),(0,$.jsx)(J,{variant:`outline`,size:`xs`,className:`!font-normal shrink-0`,disabled:!e.installable,onClick:()=>{v(e),g(!0)},children:r(`settings.skills.catalog.shared.actions.install`)})]})},`${e.sourceId}:${e.skillDir}`)})})}),F&&u.hasNextPage&&!L&&j.length>0&&(0,$.jsx)(`div`,{className:`flex justify-center mt-2 px-2`,children:(0,$.jsx)(J,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>void u.fetchNextPage(),disabled:R,children:r(R?`settings.skills.catalog.page.loading.more`:`settings.skills.catalog.page.actions.loadMoreSkills`)})})]}),(0,$.jsx)(eu,{open:p,onOpenChange:m}),(0,$.jsx)(du,{open:h,onOpenChange:g,item:_}),(0,$.jsx)(Qt,{open:x,onOpenChange:e=>{y||S(e)},children:(0,$.jsxs)(Yt,{className:`max-w-md`,children:[(0,$.jsxs)(qt,{children:[(0,$.jsx)(Xt,{children:r(`settings.skills.catalog.page.removeDialog.title`)}),(0,$.jsx)(Zt,{children:r(`settings.skills.catalog.page.removeDialog.description`)})]}),(0,$.jsxs)(Jt,{children:[(0,$.jsx)(J,{size:`sm`,variant:`ghost`,onClick:()=>S(!1),disabled:y,children:r(`settings.common.actions.cancel`)}),(0,$.jsx)(J,{size:`sm`,variant:`destructive`,onClick:()=>void B(),disabled:y,children:r(`settings.skills.catalog.page.actions.removeCatalog`)})]})]})})]})})},yu=()=>{let e=(0,Ii.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(vu,{mode:`external`,onModeChange:Ou,showModeTabs:!1}),e[0]=t):t=e[0],t},bu=`SKILL.md`,xu=`h-[clamp(320px,58dvh,680px)] min-h-[260px] max-h-[calc(100dvh-220px)]`,Su=(e,t)=>{let n=Ni({description:e}).trimEnd(),r=t.trimStart();return`---\n${n}\n---${r?`\n\n${r}`:`
|
|
22
|
+
`}`},Cu=e=>typeof e==`object`&&!!e&&!Array.isArray(e),wu=e=>{let t=e.match(/^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)([\s\S]*)$/);if(!t)return{description:null,instructions:e};let n=null;try{let e=Pi(t[1]);if(Cu(e)){let t=e.description;typeof t==`string`&&(n=t)}}catch{n=null}return{description:n,instructions:t[2].replace(/^\r?\n/,``)}},Tu=(e,t)=>Su(t,wu(e).instructions),Eu=()=>{let{t:e}=Me(),{currentTheme:t}=vr(),{selectedSkillName:n,getSkillDetail:r,createSkill:i,updateSkill:a,skillDraft:o,setSkillDraft:s,setSelectedSkill:c}=ma(le(e=>({selectedSkillName:e.selectedSkillName,getSkillDetail:e.getSkillDetail,createSkill:e.createSkill,updateSkill:e.updateSkill,skillDraft:e.skillDraft,setSkillDraft:e.setSkillDraft,setSelectedSkill:e.setSelectedSkill}))),l=ft(),u=dt(),d=Q.useMemo(()=>l.data??[],[l.data]),f=n?d.find(e=>e.name===n)??null:null,p=!!(o&&o.name===n&&!f),m=!!(n&&!f&&!o),h=f?.path===`<built-in>`;Q.useEffect(()=>{m&&c(null)},[m,c]);let[g,_]=Q.useState(``),[v,y]=Q.useState(`user`),[b,x]=Q.useState(`opencode`),[S,C]=Q.useState(``),[w,T]=Q.useState(``),[E,D]=Q.useState(()=>Su(``,``)),[O,k]=Q.useState(`edit`),[A,j]=Q.useState([]),[M,N]=Q.useState([]),[P,F]=Q.useState(!1),[I,L]=Q.useState(!1),[R,z]=Q.useState(``),[B,V]=Q.useState(``),[H,U]=Q.useState(!1),[W,ee]=Q.useState(``),[G,te]=Q.useState(``),[ne,re]=Q.useState(null),[ie,ae]=Q.useState(!1),[oe,se]=Q.useState(``),[ce,ue]=Q.useState(null),[de,fe]=Q.useState(!1),pe=p?g.trim()!==``||S.trim()!==``||w.trim()!==``||M.length>0:S!==R||w!==B,me=ne?G!==oe:W.trim()!==``,he=Q.useCallback(t=>{switch(t){case`project-opencode`:return e(`settings.skills.location.option.projectOpencode.label`);case`user-claude`:return e(`settings.skills.location.option.userClaude.label`);case`project-claude`:return e(`settings.skills.location.option.projectClaude.label`);case`user-agents`:return e(`settings.skills.location.option.userAgents.label`);case`project-agents`:return e(`settings.skills.location.option.projectAgents.label`);default:return e(`settings.skills.location.option.userOpencode.label`)}},[e]),ge=Q.useCallback(t=>{switch(t){case`project-opencode`:return e(`settings.skills.location.option.projectOpencode.description`);case`user-claude`:return e(`settings.skills.location.option.userClaude.description`);case`project-claude`:return e(`settings.skills.location.option.projectClaude.description`);case`user-agents`:return e(`settings.skills.location.option.userAgents.description`);case`project-agents`:return e(`settings.skills.location.option.projectAgents.description`);default:return e(`settings.skills.location.option.userOpencode.description`)}},[e]);Q.useEffect(()=>{(async()=>{if(p&&o){let e=o.description||``,t=o.instructions||``;_(o.name||``),y(o.scope||`user`),x(o.source===`agents`?`agents`:`opencode`),C(e),T(t),D(Su(e,t)),z(``),V(``),j([]),N(o.pendingFiles||[])}else if(n&&f){L(!0);try{let e=await r(n);if(e){let t=e.sources.md,n=t.description||``,r=t.instructions||``;C(n),T(r),D(Su(n,r)),z(n),V(r),j(t.supportingFiles||[])}}catch(e){console.error(`Failed to load skill details:`,e)}finally{L(!1)}}})()},[f,p,n,d,o,r]);let _e=K(e=>e.editorFontSize),ve=Q.useMemo(()=>{let e=[Gr(t,{fontSize:_e})],n=Rn(bu);return n&&e.push(n),e.push(De.lineWrapping),e},[t,_e]),ye=Q.useMemo(()=>{let e=W.trim()||`supporting-file.md`,n=Ar(e),r=!!n&&n!==`markdown`,i=[Gr(t,r?{syntaxColors:!1,fontSize:_e}:{fontSize:_e})],a=Rn(e);return a&&i.push(a),r&&n&&i.push(Wr({language:n,themeName:t.metadata.id,theme:Dr(t)})),i.push(De.lineWrapping),i},[t,W,_e]),be=Q.useCallback(e=>{C(e),D(t=>Tu(t,e))},[]),xe=Q.useCallback(e=>{D(e);let t=wu(e);C(t.description??``),T(t.instructions)},[]),Se=async()=>{let t=p?g.trim().replace(/\s+/g,`-`).toLowerCase():n?.trim();if(!t){Y.error(e(`settings.skills.page.toast.skillNameRequired`));return}if(!/^[a-z0-9][a-z0-9-]*[a-z0-9]$|^[a-z0-9]$/.test(t)||t.length>64){Y.error(e(`settings.skills.page.toast.invalidSkillName`));return}if(!S.trim()){Y.error(e(`settings.skills.page.toast.descriptionRequired`));return}if(p&&d.some(e=>e.name===t)){Y.error(e(`settings.skills.page.toast.skillExists`));return}F(!0);try{let n={name:t,description:S.trim(),instructions:w.trim()||void 0,scope:p?v:void 0,source:p?b:void 0,targetPath:p?void 0:f?.path,supportingFiles:p&&M.length>0?M:void 0},r;p?(r=await i(n,{directory:u}),r&&(s(null),N([]),c(t))):(r=await a(t,n,{directory:u}),r&&(z(S.trim()),V(w.trim()))),r?Y.success(e(p?`settings.skills.page.toast.skillCreated`:`settings.skills.page.toast.skillUpdated`)):Y.error(e(p?`settings.skills.page.toast.createSkillFailed`:`settings.skills.page.toast.updateSkillFailed`))}catch(t){console.error(`Error saving skill:`,t),Y.error(e(`settings.skills.page.toast.saveUnexpectedError`))}finally{F(!1)}},Ce=()=>{re(null),ee(``),te(``),se(``),U(!0)},we=async t=>{if(re(t),ee(t),p){let e=M.find(e=>e.path===t)?.content||``;te(e),se(e),U(!0);return}if(n){ae(!0),U(!0);try{let{readSupportingFile:e}=ma.getState(),r=await e(n,t);te(r||``),se(r||``)}catch{Y.error(e(`settings.skills.page.toast.loadFileContentFailed`)),te(``),se(``)}finally{ae(!1)}}},Te=async()=>{if(!W.trim()){Y.error(e(`settings.skills.page.toast.fileNameRequired`));return}let t=W.trim(),i=ne!==null;if(p){if(i)N(e=>e.map(e=>e.path===ne?{path:t,content:G}:e)),Y.success(e(`settings.skills.page.toast.fileUpdated`,{path:t}));else{if(M.some(e=>e.path===t)){Y.error(e(`settings.skills.page.toast.fileExists`));return}N(e=>[...e,{path:t,content:G}]),Y.success(e(`settings.skills.page.toast.fileAdded`,{path:t}))}U(!1),re(null);return}if(!n){Y.error(e(`settings.skills.page.toast.noSkillSelected`));return}let{writeSupportingFile:a}=ma.getState();if(await a(n,t,G)){Y.success(e(i?`settings.skills.page.toast.fileUpdated`:`settings.skills.page.toast.fileCreated`,{path:t})),U(!1),re(null);let a=await r(n);a&&j(a.sources.md.supportingFiles||[])}else Y.error(e(i?`settings.skills.page.toast.updateFileFailed`:`settings.skills.page.toast.createFileFailed`))},Ee=t=>{if(p){N(e=>e.filter(e=>e.path!==t)),Y.success(e(`settings.skills.page.toast.fileRemoved`,{path:t}));return}n&&ue(t)};return!n&&!o||m?(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center px-4`,children:(0,$.jsxs)(`div`,{className:`text-center text-muted-foreground`,children:[(0,$.jsx)(X,{name:`book-open`,className:`mx-auto mb-3 h-10 w-10 sm:h-12 sm:w-12 opacity-50`}),(0,$.jsx)(`p`,{className:`typography-body`,children:e(`settings.skills.page.empty.title`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 opacity-75`,children:e(`settings.skills.page.empty.description`)})]})}):I?(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center px-4`,children:(0,$.jsx)(`div`,{className:`text-center text-muted-foreground`,children:(0,$.jsx)(`p`,{className:`typography-body`,children:e(`settings.skills.page.loading.details`)})})}):(0,$.jsxs)(Sr,{outerClassName:`h-full`,className:`w-full`,children:[(0,$.jsxs)(`div`,{className:`oc-settings-page-content mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8`,children:[(0,$.jsx)(`div`,{children:(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`h2`,{className:`typography-ui-header font-semibold text-foreground truncate flex items-center gap-2`,children:p?e(`settings.skills.page.title.newSkill`):n}),(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground truncate`,children:f?e(`settings.skills.page.subtitle.skillLocation`,{location:he(lu(f.scope,f.source))}):e(`settings.skills.page.subtitle.newSkill`)})]})}),(0,$.jsx)(`div`,{"data-settings-item":`skills.basic-information`,children:(0,$.jsx)(vi,{label:e(`settings.skills.page.section.basicInformation`),cardClassName:`p-3`,children:(0,$.jsxs)(`div`,{className:`space-y-3`,children:[p&&(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e(`settings.skills.page.field.skillNameLocation`)}),(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground ml-2`,children:e(`settings.skills.page.field.skillNameHint`)}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 mt-1.5`,children:[(0,$.jsx)(fn,{value:g,onChange:e=>_(e.target.value.toLowerCase().replace(/\s+/g,`-`)),placeholder:e(`settings.skills.page.field.skillNamePlaceholder`),className:`h-7 w-40 px-2`}),(0,$.jsxs)(ln,{value:lu(v,b),onValueChange:e=>{let t=uu(e);y(t.scope),x(t.source===`agents`?`agents`:`opencode`)},children:[(0,$.jsxs)(rn,{className:`w-fit gap-1.5`,children:[v===`user`?(0,$.jsx)(X,{name:`user-3`,className:`h-3.5 w-3.5`}):(0,$.jsx)(X,{name:`folder`,className:`h-3.5 w-3.5`}),b===`agents`?(0,$.jsx)(X,{name:`robot-2`,className:`h-3.5 w-3.5`}):null,(0,$.jsx)(`span`,{children:he(lu(v,b))})]}),(0,$.jsx)(an,{align:`start`,children:cu.map(e=>(0,$.jsx)(tn,{value:e.value,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.scope===`user`?(0,$.jsx)(X,{name:`user-3`,className:`h-3.5 w-3.5`}):(0,$.jsx)(X,{name:`folder`,className:`h-3.5 w-3.5`}),e.source===`agents`?(0,$.jsx)(X,{name:`robot-2`,className:`h-3.5 w-3.5`}):null,(0,$.jsx)(`span`,{children:he(e.value)})]}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground ml-6`,children:ge(e.value)})]})},e.value))})]})]})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`span`,{className:`typography-ui-label text-foreground`,children:[e(`settings.common.field.description`),` `,(0,$.jsx)(`span`,{className:`text-[var(--status-error)]`,children:`*`})]}),(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground ml-2`,children:e(`settings.skills.page.field.descriptionHint`)}),(0,$.jsx)(`div`,{className:`mt-1.5`,children:(0,$.jsx)(Cr,{embedded:!0,value:S,onChange:e=>be(e.target.value),placeholder:e(`settings.skills.page.field.descriptionPlaceholder`),rows:2,className:`w-full resize-none min-h-[60px] max-h-32 bg-transparent`,disabled:h})})]})]})})}),(0,$.jsx)(`div`,{"data-settings-item":`skills.instructions`,children:(0,$.jsx)(vi,{label:(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{children:e(`settings.skills.page.section.instructions`)}),(0,$.jsx)(ci,{currentMode:O===`preview`?`preview`:`edit`,onToggle:()=>k(e=>e===`preview`?`edit`:`preview`)})]}),cardClassName:`p-3`,children:(0,$.jsx)(`div`,{className:q(`overflow-hidden bg-background`,xu),children:O===`preview`?(0,$.jsx)(Sr,{outerClassName:`h-full`,className:`h-full`,children:(0,$.jsx)(`div`,{className:`min-h-full px-4 py-3`,children:(0,$.jsx)(Or,{content:E,className:`typography-markdown-body`,stripFrontmatter:!0,enableFileReferences:!1})})}):(0,$.jsx)(qr,{value:E,onChange:xe,readOnly:h,extensions:ve,className:`h-full`,enableSearch:!0})})})}),(0,$.jsx)(`div`,{"data-settings-item":`skills.supporting-files`,children:(0,$.jsx)(vi,{label:(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{children:e(`settings.skills.page.section.supportingFiles`)}),(0,$.jsxs)(J,{variant:`outline`,size:`xs`,className:`!font-normal gap-1`,onClick:Ce,disabled:h,children:[(0,$.jsx)(X,{name:`add`,className:`h-3.5 w-3.5`}),` `,e(`settings.skills.page.actions.addFile`)]})]}),cardClassName:`p-3`,children:(()=>{let t=p?M:A;return t.length===0?(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground py-1.5`,children:e(`settings.skills.page.supportingFiles.empty`)}):(0,$.jsx)(`div`,{className:`divide-y divide-[var(--surface-subtle)]`,children:t.map(t=>(0,$.jsxs)(`div`,{className:`flex items-center gap-2 py-1.5 cursor-pointer group`,onClick:()=>we(t.path),children:[(0,$.jsx)(X,{name:`file`,className:`h-3.5 w-3.5 text-muted-foreground flex-shrink-0`}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground truncate`,children:t.path}),p&&(0,$.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:e(`settings.skills.page.badge.pending`)}),!h&&(0,$.jsx)(J,{size:`sm`,variant:`ghost`,className:`h-5 w-5 px-0 flex-shrink-0 text-muted-foreground hover:text-[var(--status-error)] opacity-0 group-hover:opacity-100 transition-opacity`,onClick:e=>{e.stopPropagation(),Ee(t.path)},children:(0,$.jsx)(X,{name:`delete-bin`,className:`h-3 w-3`})})]},t.path))})})()})}),(0,$.jsx)(`div`,{children:(0,$.jsx)(J,{onClick:Se,disabled:h||P||!pe,size:`xs`,className:`!font-normal`,children:e(P?`settings.common.actions.saving`:p?`settings.skills.page.actions.createSkill`:`settings.common.actions.saveChanges`)})})]}),(0,$.jsx)(Qt,{open:ce!==null,onOpenChange:e=>{!e&&!de&&ue(null)},children:(0,$.jsxs)(Yt,{className:`max-w-md`,children:[(0,$.jsxs)(qt,{children:[(0,$.jsx)(Xt,{children:e(`settings.skills.page.deleteFileDialog.title`)}),(0,$.jsx)(Zt,{children:e(`settings.skills.page.deleteFileDialog.description`,{path:ce??``})})]}),(0,$.jsxs)(Jt,{children:[(0,$.jsx)(J,{size:`sm`,variant:`ghost`,onClick:()=>ue(null),disabled:de,children:e(`settings.common.actions.cancel`)}),(0,$.jsx)(J,{size:`sm`,variant:`destructive`,onClick:async()=>{if(!ce||!n)return;fe(!0);let{deleteSupportingFile:t}=ma.getState();if(await t(n,ce)){Y.success(e(`settings.skills.page.toast.fileDeleted`,{path:ce}));let t=await r(n);t&&j(t.sources.md.supportingFiles||[]),ue(null)}else Y.error(e(`settings.skills.page.toast.deleteFileFailed`));fe(!1)},disabled:de,children:e(`settings.common.actions.delete`)})]})]})}),(0,$.jsx)(Qt,{open:H,onOpenChange:e=>{U(e),e||re(null)},children:(0,$.jsxs)(Yt,{className:`max-w-3xl max-h-[85vh] flex flex-col`,children:[(0,$.jsxs)(qt,{className:`flex-shrink-0`,children:[(0,$.jsx)(Xt,{children:e(ne?`settings.skills.page.fileDialog.titleEdit`:`settings.skills.page.fileDialog.titleAdd`)}),(0,$.jsx)(Zt,{children:e(ne?`settings.skills.page.fileDialog.descriptionEdit`:`settings.skills.page.fileDialog.descriptionAdd`)})]}),ie?(0,$.jsx)(`div`,{className:`flex-1 flex items-center justify-center py-8`,children:(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:e(`settings.skills.page.loading.fileContent`)})}):(0,$.jsxs)(`div`,{className:`space-y-4 flex-1 min-h-0 flex flex-col pt-2`,children:[(0,$.jsxs)(`div`,{className:`space-y-2 flex-shrink-0`,children:[(0,$.jsx)(`label`,{className:`typography-ui-label font-medium text-foreground`,children:e(`settings.skills.page.fileDialog.field.filePath`)}),(0,$.jsx)(fn,{value:W,onChange:e=>ee(e.target.value),placeholder:e(`settings.skills.page.fileDialog.field.filePathPlaceholder`),className:`text-foreground placeholder:text-muted-foreground focus-visible:ring-[var(--primary-base)]`,disabled:ne!==null}),!ne&&(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground`,children:e(`settings.skills.page.fileDialog.field.filePathHint`)})]}),(0,$.jsxs)(`div`,{className:`space-y-2 flex-1 min-h-0 flex flex-col`,children:[(0,$.jsx)(`label`,{className:`typography-ui-label font-medium text-foreground flex-shrink-0`,children:e(`settings.skills.page.fileDialog.field.content`)}),(0,$.jsx)(`div`,{className:`h-[45vh] min-h-[250px] max-h-[55vh] overflow-hidden rounded-md border border-[var(--surface-subtle)] bg-background`,children:(0,$.jsx)(qr,{value:G,onChange:te,extensions:ye,className:`h-full`,enableSearch:!0})})]})]}),(0,$.jsxs)(Jt,{className:`mt-4`,children:[(0,$.jsx)(J,{size:`sm`,variant:`ghost`,onClick:()=>{U(!1),re(null)},children:e(`settings.common.actions.cancel`)}),(0,$.jsx)(J,{size:`sm`,onClick:Te,disabled:ie||!me,children:e(ne?`settings.common.actions.saveChanges`:`settings.skills.page.actions.createFile`)})]})]})})]})},Du=e=>{let t=(0,Ii.c)(2),{view:n}=e,r=n===void 0?`installed`:n,i;return t[0]===r?i=t[1]:(i=r===`catalog`?(0,$.jsx)(yu,{}):(0,$.jsx)(Eu,{}),t[0]=r,t[1]=i),i};function Ou(){}var ku=e=>{let t=(0,Ii.c)(26),{onItemSelect:n}=e,{t:r}=Me(),i=Ct(Au),a=Ct(ju),o=K(Mu),s=K(Nu),c=Q.useRef(null),l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=new Set,t[0]=l):l=t[0];let u=Q.useRef(l),d;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(d=k(),t[1]=d):d=t[1];let f=d,p=Pu,m,h;t[2]!==a||t[3]!==i||t[4]!==o||t[5]!==s?(m=()=>{let e=new Set(i.map(Fu)),t=c.current;if(t)for(let n of e)t.has(n)||u.current.add(n);if(c.current=e,a&&u.current.delete(a)){s(a);return}if(i.length===0){o!==null&&s(null);return}o&&i.some(e=>e.id===o)||s(i[0].id)},h=[a,i,o,s],t[2]=a,t[3]=i,t[4]=o,t[5]=s,t[6]=m,t[7]=h):(m=t[6],h=t[7]),Q.useEffect(m,h);let g;t[8]!==i.length||t[9]!==r?(g=r(`settings.projects.sidebar.total`,{count:i.length}),t[8]=i.length,t[9]=r,t[10]=g):g=t[10];let _;t[11]===g?_=t[12]:(_=(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:g}),t[11]=g,t[12]=_);let v;t[13]===r?v=t[14]:(v=!f&&(0,$.jsx)(J,{type:`button`,variant:`ghost`,size:`icon`,className:`h-7 w-7 -my-1 text-muted-foreground`,onClick:p,"aria-label":r(`settings.projects.sidebar.actions.addProject`),children:(0,$.jsx)(X,{name:`add`,className:`size-4`})}),t[13]=r,t[14]=v);let y;t[15]!==_||t[16]!==v?(y=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-2 px-[var(--oc-settings-row-inset)]`,children:[_,v]}),t[15]=_,t[16]=v,t[17]=y):y=t[17];let b;t[18]!==n||t[19]!==i||t[20]!==o||t[21]!==s?(b=i.length>0?(0,$.jsx)(vi,{children:i.map(e=>{let t=e.id===o,r=e.icon?on[e.icon]:null,i=e.color?un[e.color]:void 0,a=(0,$.jsx)(X,{name:r??`folder`,className:`h-4 w-4`,style:i?{color:i}:void 0}),c=(0,$.jsx)(`span`,{className:q(`flex size-5 shrink-0 items-center justify-center overflow-hidden`,t?`text-foreground`:`text-muted-foreground`),children:e.iconImage?(0,$.jsx)(nn,{project:e,className:`size-full object-contain`,fallback:a}):a});return(0,$.jsx)(yo,{title:e.path.split(/[\\/]/).filter(Boolean).at(-1)||e.path,icon:c,selected:t,onSelect:()=>{s(e.id),n?.()}},e.id)})}):null,t[18]=n,t[19]=i,t[20]=o,t[21]=s,t[22]=b):b=t[22];let x;return t[23]!==y||t[24]!==b?(x=(0,$.jsx)(xo,{variant:`background`,header:y,children:b}),t[23]=y,t[24]=b,t[25]=x):x=t[25],x};function Au(e){return e.projects}function ju(e){return e.activeProjectId}function Mu(e){return e.settingsProjectsSelectedId}function Nu(e){return e.setSettingsProjectsSelectedId}function Pu(){Ut.requestDirectoryDialog()}function Fu(e){return e.id}var Iu=()=>{let e=(0,Ii.c)(18),{t}=Me(),n=Ct(Lu),r=Ct(Ru),i=K(zu),a=K(Bu),o;bb0:{if(!i){o=null;break bb0}let t;e[0]!==n||e[1]!==i?(t=n.find(e=>e.id===i)??null,e[0]=n,e[1]=i,e[2]=t):t=e[2],o=t}let s=o,c,l;e[3]!==n||e[4]!==i||e[5]!==a?(c=()=>{if(n.length===0){a(null);return}i&&n.some(e=>e.id===i)||a(n[0].id)},l=[n,i,a],e[3]=n,e[4]=i,e[5]=a,e[6]=c,e[7]=l):(c=e[6],l=e[7]),Q.useEffect(c,l);let u;e[8]!==s||e[9]!==r?(u=async e=>{s&&r(s.id,{label:e.label,icon:e.icon,color:e.color,iconBackground:e.iconBackground,defaultModel:e.defaultModel??null})},e[8]=s,e[9]=r,e[10]=u):u=e[10];let d=u;if(!s){let n;e[11]===t?n=e[12]:(n=t(`settings.projects.page.empty.noProjects`),e[11]=t,e[12]=n);let r;return e[13]===n?r=e[14]:(r=(0,$.jsx)(Sr,{outerClassName:`h-full`,className:`w-full`,children:(0,$.jsx)(`div`,{className:`mx-auto w-full max-w-4xl p-3 sm:p-6 sm:pt-8`,children:(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:n})})}),e[13]=n,e[14]=r),r}let f;return e[15]!==d||e[16]!==s?(f=(0,$.jsx)(Sr,{outerClassName:`h-full`,className:`w-full bg-background`,children:(0,$.jsx)(`div`,{className:`mx-auto w-full max-w-4xl p-3 sm:p-6 sm:pt-8`,children:(0,$.jsx)(Kr,{project:s,onIdentitySave:d})})}),e[15]=d,e[16]=s,e[17]=f):f=e[17],f};function Lu(e){return e.projects}function Ru(e){return e.updateProjectMeta}function zu(e){return e.settingsProjectsSelectedId}function Bu(e){return e.setSettingsProjectsSelectedId}var Vu=e(Fi(),1),Hu=16384,Uu=globalThis,Wu=e=>{if(Uu.Buffer)return Uu.Buffer.from(e,`utf8`).toString(`base64url`);let t=new TextEncoder().encode(e),n=``;for(let e=0;e<t.length;e+=32768)n+=String.fromCharCode(...t.slice(e,e+32768));return btoa(n).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/g,``)},Gu=e=>{try{if(Uu.Buffer)return Uu.Buffer.from(e,`base64url`).toString(`utf8`);let t=e.replace(/-/g,`+`).replace(/_/g,`/`).padEnd(Math.ceil(e.length/4)*4,`=`),n=atob(t),r=new Uint8Array(n.length);for(let e=0;e<n.length;e+=1)r[e]=n.charCodeAt(e);return new TextDecoder().decode(r)}catch{return null}},Ku=e=>{if(typeof e!=`string`)return null;let t=e.trim();if(!t)return null;try{let e=new URL(t);return e.protocol!==`http:`&&e.protocol!==`https:`?null:(e.hash=``,e.toString().replace(/\/+$/g,``))}catch{return null}},qu=e=>{if(typeof e!=`string`)return null;let t=e.trim();if(!t)return null;try{let e=new URL(t);return e.protocol!==`ws:`&&e.protocol!==`wss:`||e.username||e.password?null:(e.username=``,e.password=``,e.hash=``,e.search=``,e.toString())}catch{return null}},Ju=e=>typeof e==`string`&&e.length>0,Yu=e=>{if(!e||typeof e!=`object`||Array.isArray(e))return null;let t=e;return t.kty!==`EC`||t.crv!==`P-256`||!Ju(t.x)||!Ju(t.y)?null:{kty:`EC`,crv:`P-256`,x:t.x,y:t.y}},Xu=e=>typeof e==`number`&&Number.isFinite(e)?e:void 0,Zu=e=>{if(!e||typeof e!=`object`)return null;let t=e,n=Xu(t.priority);if(t.type===`lan`||t.type===`tunnel`){let e=Ku(t.url);return e?n===void 0?{type:t.type,url:e}:{type:t.type,url:e,priority:n}:null}if(t.type===`relay`){let e=qu(t.relayUrl);if(!e)return null;let r=typeof t.serverId==`string`?t.serverId.trim():``;if(!r)return null;let i=Yu(t.hostEncPubJwk);if(!i)return null;let a=typeof t.grant==`string`&&t.grant.trim()?t.grant.trim():void 0;return{type:`relay`,relayUrl:e,serverId:r,hostEncPubJwk:i,...a?{grant:a}:{},...n===void 0?{}:{priority:n}}}return null},Qu=e=>{if(!e||typeof e!=`object`)return null;let t=e;if(t.v!==2)return null;let n=typeof t.pairingId==`string`?t.pairingId.trim():``,r=typeof t.secret==`string`?t.secret.trim():``;if(!n||!r)return null;let i=Array.isArray(t.candidates)?t.candidates.map(Zu).filter(e=>!!e):[];if(i.length===0)return null;let a=typeof t.expiresAt==`string`&&t.expiresAt.trim()?t.expiresAt.trim():void 0;if(a){let e=Date.parse(a);if(!Number.isFinite(e)||e<=Date.now())return null}let o=typeof t.label==`string`&&t.label.trim()?t.label.trim():void 0,s=typeof t.fingerprint==`string`&&t.fingerprint.trim()?t.fingerprint.trim():void 0;return{v:2,pairingId:n,secret:r,...o?{label:o}:{},...s?{fingerprint:s}:{},...a?{expiresAt:a}:{},candidates:i}},$u=e=>({v:2,pairingId:e.pairingId.trim(),secret:e.secret.trim(),...e.label?.trim()?{label:e.label.trim()}:{},...e.fingerprint?.trim()?{fingerprint:e.fingerprint.trim()}:{},...e.expiresAt?.trim()?{expiresAt:e.expiresAt.trim()}:{},candidates:e.candidates}),ed=e=>{let t=Qu(e);if(!t)throw Error(`Invalid pairing connection payload`);let n=new URLSearchParams;return n.set(`v`,`2`),n.set(`p`,Wu(JSON.stringify(t))),`openchamber://connect?${n.toString()}`},td=e=>{let t=e.trim();if(!t||t.length>Hu)return null;let n=t.indexOf(`?`);if(n===-1||!/^openchamber:\/\/connect\/?$/i.test(t.slice(0,n)))return null;let r=null,i=null;for(let e of t.slice(n+1).split(`&`)){let t=e.indexOf(`=`);if(t===-1)continue;let n=e.slice(0,t),a=e.slice(t+1);n===`v`?r=a:n===`p`&&(i=a)}if(r!==`2`||!i||i.length>Hu)return null;let a=Gu(i);if(!a||a.length>Hu)return null;try{return Qu(JSON.parse(a))}catch{return null}},nd=e=>{let t=e.trim();if(!t||t.length>Hu)return null;try{let e=new URL(t);if(e.protocol===`openchamber:`&&e.hostname===`connect`){if(e.searchParams.get(`v`)!==`2`)return null;let t=e.searchParams.get(`p`)||``;if(!t||t.length>Hu)return null;let n=Gu(t);return!n||n.length>Hu?null:Qu(JSON.parse(n))}}catch{}return td(t)},rd=`relay_identity_changed`,id=class extends Error{code=rd;expectedServerId;actualServerId;constructor(e,t){super(`Relay identity changed (expected ${e}, got ${t||`unknown`})`),this.name=`RelayIdentityChangedError`,this.expectedServerId=e,this.actualServerId=t}},ad=new Map,od=e=>{let t=e.trim();if(!t)throw Error(`Relay serverId is required`);return`relay:${t}`},sd=e=>{let t={Accept:`application/json`},n=typeof e.clientToken==`string`?e.clientToken.trim():``;if(n&&(t.Authorization=`Bearer ${n}`),e.requestHeaders)for(let[n,r]of Object.entries(e.requestHeaders))!n.trim()||!r.trim()||n.trim().toLowerCase()!==`authorization`&&(t[n.trim()]=r.trim());return t},cd=e=>({files:e?.files?.length??0,directories:e?.directories?.length??0,deletes:e?.deletes?.length??0,totalBytes:e?.totalBytes??0}),ld=async e=>{x()&&await b(`desktop_sync_runs_append`,{record:e})},ud=async(e,t)=>{if(!t)return;let n=await t().catch(()=>null),r=typeof n?.serverId==`string`?n.serverId.trim():``;if(r&&r!==e)throw new id(e,r)},dd=e=>({ok:!0,files:0,directories:0,deletes:e.deletes.length,totalBytes:0,agentsRoot:null,authFile:null,plan:e}),fd=e=>{let t=e?.selectionShape;if(!t)throw Error(`Local sync inventory missing selectionShape (update the OpenChamber desktop app)`);return t},pd=(e,t)=>{let n=Bn(e,{includeAuthFile:!1}),r=t.selections;return{fileGroups:r?.fileGroups??n.fileGroups,singleFiles:r?.singleFiles??n.singleFiles,directories:r?.directories??n.directories,agentsRoot:r?.agentsRoot!==!1,authFile:r?.authFile===!0}},md=(e,t,n)=>{let r=e.inventory&&typeof e.inventory==`object`?e.inventory:null;return{direction:`pull`,files:r?.files??t?.files??[],directories:r?.directories??t?.directories??[],agentsRoot:n.agentsRoot?r?.agentsRoot??null:null,authFile:n.authFile?r?.authFile??null:null,deletes:t?.deletes??[],totalBytes:t?.totalBytes??0,selections:n}},hd=(e,t)=>({...e,direction:`push`,authFile:t.authFile?e.authFile:null,agentsRoot:t.agentsRoot?e.agentsRoot:null,selections:t}),gd=e=>e.files.length>0||e.directories.length>0||!!e.agentsRoot||!!e.authFile,_d=(e,t)=>{let r=n({relayUrl:e.relayUrl,serverId:e.serverId,hostEncPubJwk:e.hostEncPubJwk}),i=sd(t),a=async(e,t,n)=>{let a=await r.fetch(t,{method:e,headers:{...i,...n===void 0?{}:{"Content-Type":`application/json`}},body:n===void 0?void 0:JSON.stringify(n)}),o=await a.json().catch(()=>({}));if(!a.ok){let n=Error(typeof o.error==`string`?o.error:`Relay sync ${e} ${t} failed (${a.status})`);throw typeof o.code==`string`&&(n.code=o.code),n}return o};return{tunnel:r,async probe(e){let t=await a(`POST`,`/api/openchamber/config-sync/probe`,{plan:e});return{remoteExisting:Array.isArray(t.remoteExisting)?t.remoteExisting:[],remoteAgentsRootExists:t.remoteAgentsRootExists===!0,remoteAuthFileExists:t.remoteAuthFileExists===!0,inventory:t.inventory}},async prepare(e,t){await a(`POST`,`/api/openchamber/config-sync/prepare`,{plan:e,syncRunId:t})},async putTar(e,t,n){let a=await r.fetch(`/api/openchamber/config-sync/put/${encodeURIComponent(e)}?syncRunId=${encodeURIComponent(n)}`,{method:`PUT`,headers:{...i,"Content-Type":`application/gzip`},body:new Blob([new Uint8Array(t)],{type:`application/gzip`})}),o=await a.json().catch(()=>({}));if(!a.ok){let t=Error(typeof o.error==`string`?o.error:`Relay sync put ${e} failed (${a.status})`);throw typeof o.code==`string`&&(t.code=o.code),t}},async download(e){let t=await r.fetch(`/api/openchamber/config-sync/download/${encodeURIComponent(e)}`,{method:`GET`,headers:i});if(!t.ok){let n=await t.json().catch(()=>({})),r=Error(typeof n.error==`string`?n.error:`Relay sync download ${e} failed (${t.status})`);throw typeof n.code==`string`&&(r.code=n.code),r}return new Uint8Array(await t.arrayBuffer())},async finalize(e){await a(`POST`,`/api/openchamber/config-sync/finalize`,{syncRunId:e})},async abort(e){await a(`POST`,`/api/openchamber/config-sync/abort`,{syncRunId:e}).catch(()=>void 0)},close(){r.close()}}},vd=async(e,t,n,r)=>{if(ad.has(e)){let t=Error(`Config sync already in progress for ${e}`);throw t.code=`sync_in_progress`,t}let i=crypto.randomUUID(),a=new Date().toISOString();ad.set(e,i);try{let o=await r({syncRunId:i});return await ld({syncRunId:i,targetId:e,stage:t,direction:n,startedAt:a,endedAt:new Date().toISOString(),result:`success`,summary:cd(o.plan)}),{...o,syncRunId:i}}catch(r){throw await ld({syncRunId:i,targetId:e,stage:t,direction:n,startedAt:a,endedAt:new Date().toISOString(),result:`failure`,summary:cd(null),error:r instanceof Error?r.message:String(r)}).catch(()=>void 0),r}finally{ad.get(e)===i&&ad.delete(e)}},yd=async(e,t)=>{let n=await dr({direction:e,targetKind:`relay`}),r=fd(n),i=pd(r,t),a=e===`push`?await dr({direction:e,selections:i,targetKind:`relay`}):n;if(e===`push`&&!a)throw Error(`Local sync inventory unavailable`);return{selectionShape:r,selections:i,localPlan:a}},bd=async(e,t={},n={})=>{let r=e.relay,i=od(r.serverId),a=t.direction===`pull`?`pull`:`push`;return vd(i,`preview`,a,async()=>{await ud(r.serverId,n.refreshCandidates);let{selectionShape:i,selections:o,localPlan:s}=await yd(a,t),c=_d(r,e);try{if(a===`pull`){let e=await c.probe({});return{plan:md(e,s,o),remoteExisting:e.remoteExisting,remoteAgentsRootExists:e.remoteAgentsRootExists,remoteAuthFileExists:e.remoteAuthFileExists,selectionShape:i}}let e=hd(s,o),t=await c.probe(e);return{plan:e,remoteExisting:t.remoteExisting,remoteAgentsRootExists:t.remoteAgentsRootExists,remoteAuthFileExists:t.remoteAuthFileExists,selectionShape:s?.selectionShape??i}}finally{c.close()}})},xd=async(e,t={},n={})=>{let r=e.relay,i=od(r.serverId),a=t.direction===`pull`?`pull`:`push`;return vd(i,`apply`,a,async({syncRunId:i})=>{await ud(r.serverId,n.refreshCandidates);let{selections:o,localPlan:s}=await yd(a,t),c=_d(r,e);try{if(a===`pull`){let e=md(await c.probe({}),s,o);if(!gd(e))return dd(e);let t=e.files.length>0||e.directories.length>0?await c.download(`config`):null,n=e.agentsRoot?await c.download(`agents`):null,r=e.authFile?await c.download(`auth`):null;if(!x())throw Error(`Relay pull apply requires the OpenChamber desktop app`);let a=await b(`desktop_relay_sync_apply_local`,{syncRunId:i,plan:e,configTar:t,agentsTar:n,authTar:r});if(!a?.ok)throw Error(`Relay pull local apply failed`);return{...a,plan:e}}let e=hd(s,o);if(!gd(e))return dd(e);if(!x())throw Error(`Relay push apply requires the OpenChamber desktop app`);let t=await b(`desktop_relay_sync_pack_local`,{plan:e});if(!t)throw Error(`Relay push local pack failed`);await c.prepare(e,i);try{t.configTar&&t.configTar.byteLength>0&&await c.putTar(`config`,t.configTar,i),t.agentsTar&&t.agentsTar.byteLength>0&&await c.putTar(`agents`,t.agentsTar,i),t.authTar&&t.authTar.byteLength>0&&await c.putTar(`auth`,t.authTar,i),await c.finalize(i)}catch(e){throw await c.abort(i),e}return{ok:!0,files:e.files.length,directories:e.directories.length,deletes:e.deletes.length,totalBytes:e.totalBytes,agentsRoot:e.agentsRoot?{fileCount:e.agentsRoot.fileCount}:null,authFile:e.authFile?{bytes:e.authFile.bytes}:null,plan:e}}finally{c.close()}})},Sd=()=>{let{t:e}=Me(),t=u()&&_(),[n,r]=Q.useState(!1),[i,a]=Q.useState(!1),[o,s]=Q.useState(``),[d,f]=Q.useState(``),[p,m]=Q.useState(!1),[h,g]=Q.useState(null),[v,b]=Q.useState(!0),[x,S]=Q.useState(!1),[C,w]=Q.useState(null),[T,E]=Q.useState(null);Q.useEffect(()=>{if(!t){b(!1);return}let n=!1;return(async()=>{try{let t=await l(`/api/config/settings`,{method:`GET`,headers:{Accept:`application/json`}});if(!t.ok)throw Error(e(`settings.openchamber.desktopNetwork.error.loadFailed`));let i=await t.json().catch(()=>null);if(n)return;let o=i?.desktopLanAccessEnabled===!0,c=typeof i?.desktopUiPassword==`string`?i.desktopUiPassword:``;r(o),a(o),s(c),f(c),m(i?.desktopLanAccessActive===!0),g(typeof i?.desktopLanAccessBlockedReason==`string`?i.desktopLanAccessBlockedReason:null),w(null)}catch(t){n||w(t instanceof Error?t.message:e(`settings.openchamber.desktopNetwork.error.loadFailed`))}finally{n||b(!1)}})(),()=>{n=!0}},[t,e]),Q.useEffect(()=>{if(!t||!i){E(null);return}let e=!1;return(async()=>{let t=await y();e||E(t)})(),()=>{e=!0}},[i,t]);let D=i!==n||d!==o,O=Q.useMemo(()=>{if(typeof window>`u`)return null;let e=c()||window.location.href,t=0;try{t=Number(new URL(e).port)}catch{t=Number(window.location.port)}return Number.isFinite(t)&&t>0?t:null},[]),k=i&&p&&T&&O?`http://${T}:${O}`:null,A=i&&!d.trim(),M=n&&!p&&h===`missing-password`,N=v||x||!D||A,P=Q.useCallback(()=>{a(e=>!e)},[]),F=Q.useCallback(e=>{f(e),e.trim()||a(!1)},[]),I=Q.useCallback(async()=>{if(D){S(!0),w(null);try{if(!(await l(`/api/config/settings`,{method:`PUT`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({desktopLanAccessEnabled:i,desktopUiPassword:d})})).ok)throw Error(e(`settings.openchamber.desktopNetwork.error.saveFailed`));if(r(i),s(d),!await j())throw Error(e(`settings.openchamber.desktopNetwork.error.savedRestartFailed`))}catch(t){w(t instanceof Error?t.message:e(`settings.openchamber.desktopNetwork.error.saveFailed`)),S(!1)}}},[d,i,D,e]);return t?(0,$.jsxs)(vi,{className:`oc-settings-detail-group`,label:e(`settings.openchamber.desktopNetwork.title`),children:[(0,$.jsx)(Nr,{itemId:`remote-instances.desktop-ui-password`,label:(0,$.jsx)(`label`,{htmlFor:`desktop-ui-password`,children:e(`settings.openchamber.desktopPassword.field.password`)}),description:e(`settings.openchamber.desktopPassword.field.passwordDescription`),children:(0,$.jsx)(fn,{id:`desktop-ui-password`,type:`password`,className:`max-w-sm`,value:d,onChange:e=>F(e.target.value),placeholder:e(`settings.openchamber.desktopPassword.field.passwordPlaceholder`),disabled:v||x,required:i,"aria-invalid":A})}),(0,$.jsxs)(`div`,{"data-settings-item":`remote-instances.desktop-lan-access`,className:`oc-settings-group-row oc-settings-split-row group cursor-pointer`,role:`button`,tabIndex:0,onClick:P,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),P())},children:[(0,$.jsxs)(`div`,{className:`oc-settings-split-row-copy`,children:[(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:e(`settings.openchamber.desktopNetwork.field.allowLanAccess`)}),(0,$.jsx)(`div`,{className:`typography-meta text-muted-foreground`,children:e(`settings.openchamber.desktopNetwork.field.allowLanAccessDescription`)}),(0,$.jsx)(`div`,{className:`typography-meta text-[var(--status-warning)]/85`,children:e(`settings.openchamber.desktopNetwork.field.warning`)}),A||M?(0,$.jsx)(`div`,{className:`typography-meta text-[var(--status-warning)]/85`,children:e(`settings.openchamber.desktopNetwork.field.passwordRequiredWarning`)}):null]}),(0,$.jsx)(`div`,{className:`oc-settings-split-row-control`,children:(0,$.jsx)(sn,{checked:i,onChange:P,ariaLabel:e(`settings.openchamber.desktopNetwork.field.allowLanAccessAria`),disabled:v||x})})]}),C?(0,$.jsx)(`div`,{className:`oc-settings-group-row typography-meta text-[var(--status-error)]`,children:C}):null,k?(0,$.jsxs)(`div`,{className:`oc-settings-group-row typography-meta text-muted-foreground`,children:[e(D&&!n?`settings.openchamber.desktopNetwork.hint.openAfterRestart`:`settings.openchamber.desktopNetwork.hint.openNow`),(0,$.jsx)(`span`,{className:`font-mono text-foreground`,children:k})]}):null,(0,$.jsx)(`div`,{className:`oc-settings-group-row flex justify-end`,children:(0,$.jsx)(J,{type:`button`,size:`xs`,onClick:I,disabled:N,className:`shrink-0 !font-normal`,children:e(x?`settings.common.actions.saving`:`settings.openchamber.desktopNetwork.actions.saveAndRestart`)})})]}):null},Cd=`wss://relay.openchamber.dev/ws`,wd=`openchamber.pairing.relayUrl.v1`,Td=e=>{if(typeof e!=`string`||!e.trim())return null;try{let t=new URL(e.trim());return t.protocol!==`ws:`&&t.protocol!==`wss:`||t.username||t.password?null:(t.username=``,t.password=``,t.hash=``,t.search=``,t.toString())}catch{return null}},Ed=(e=typeof window>`u`?null:window.localStorage)=>{if(!e)return null;try{return Td(e.getItem(wd))}catch{return null}},Dd=(e,t=typeof window>`u`?null:window.localStorage)=>{if(!t)return;let n=Td(e);if(n)try{t.setItem(wd,n)}catch{}},Od=`https://github.com/yee94/openchamber/tree/main/packages/relay-server`,kd=()=>Math.floor(2e4+Math.random()*3e4),Ad=e=>{if(!Number.isFinite(e)||e<0)return`0 B`;if(e<1024)return`${e} B`;let t=[`KB`,`MB`,`GB`,`TB`],n=e/1024;for(let e of t){if(n<1024||e===t[t.length-1])return`${n.toFixed(n>=10?0:1)} ${e}`;n/=1024}return`${e} B`},jd={fileGroups:[],singleFiles:[],directories:[],agentsRoot:!0,authFile:!1},Md=e=>{let t=e.selectionShape;if(!t||typeof t!=`object`)return null;let n=typeof t.fileGroups==`number`?t.fileGroups:null,r=typeof t.singleFiles==`number`?t.singleFiles:null,i=typeof t.directories==`number`?t.directories:null;return n===null||r===null||i===null||n<0||r<0||i<0?null:{fileGroups:n,singleFiles:r,directories:i}},Nd=(e,t)=>e.fileGroups.length===t.fileGroups&&e.singleFiles.length===t.singleFiles&&e.directories.length===t.directories,Pd=[`settings.remoteInstances.page.sync.step.scanLocal`,`settings.remoteInstances.page.sync.step.compareRemote`,`settings.remoteInstances.page.sync.step.confirm`],Fd=({open:e,instanceId:t,targetKind:n=`ssh`,relayHost:r=null,onOpenChange:i})=>{let{t:a}=Me(),[o,s]=Q.useState(1),[c,l]=Q.useState(`scanning-local`),[u,d]=Q.useState(`push`),[f,p]=Q.useState(jd),[m,h]=Q.useState(null),[g,_]=Q.useState(null),[v,y]=Q.useState(null),[b,x]=Q.useState(null),[S,C]=Q.useState(null),w=Q.useRef(jd),T=m!=null&&Nd(f,m),E=Ae(()=>{s(1),l(`scanning-local`),d(`push`),p(jd),h(null),_(null),y(null),x(null),C(null),w.current=jd}),D=Ae(async(e=u,i=f)=>{if(t){s(2),l(`comparing-remote`),x(null),C(null),y(null);try{let o=n===`relay`?r?await bd(r,{direction:e,selections:i}):null:await ir(t,{targetKind:n,direction:e,selections:i});if(!o){x(a(`settings.remoteInstances.page.sync.state.unavailable`)),C(2),l(`error`);return}y(o),w.current=i,s(3),l(`review`)}catch(e){console.error(`[remote-instances] config sync compare-remote failed`,e),x(e instanceof Error?e.message:String(e)),C(2),l(`error`)}}}),O=Ae(async(e=u,r=f)=>{if(t){s(1),l(`scanning-local`),x(null),C(null),_(null),y(null);try{let t=m!=null&&Nd(r,m),i=await dr(t?{targetKind:n,direction:e,selections:r}:{targetKind:n,direction:e});if(!i){h(null),x(a(`settings.remoteInstances.page.sync.state.unavailable`)),C(1),l(`error`);return}let o=Md(i);if(!o){h(null),p(jd),x(a(`settings.remoteInstances.page.sync.state.unavailable`)),C(1),l(`error`);return}h(o);let s=t?r:Bn(o,{includeAuthFile:!1});p(s),_(i),await D(e,s)}catch(e){console.error(`[remote-instances] config sync scan-local failed`,e),x(e instanceof Error?e.message:String(e)),C(1),l(`error`)}}});Q.useEffect(()=>{!e||!t||O(`push`)},[e,t]),Q.useEffect(()=>{e||E()},[e]);let k=Q.useMemo(()=>new Set(v?.remoteExisting??[]),[v]),A=v?.plan??g,j=!!(A&&(A.files.length>0||A.directories.length>0||A.agentsRoot!=null||A.authFile!=null)),M=c===`applying`,N=c===`review`||c===`applying`&&o===3,P=A?A.deletes.length+(A.agentsRoot&&v?.remoteAgentsRootExists?1:0):0,F=Ae(()=>{if(S===2){D(u,f);return}O(u,f)}),I=Ae(e=>{e===u||M||(d(e),y(null),_(null),O(e,f))}),L=Ae(async()=>{if(!(!t||!j||M||c!==`review`)){l(`applying`);try{if(!(n===`relay`?r&&await xd(r,{direction:u,selections:w.current}):await Jn(t,{targetKind:n,direction:u,selections:w.current})))throw Error(`Sync bridge unavailable`);Y.success(a(`settings.remoteInstances.page.sync.toast.success`)),i(!1)}catch(e){console.error(`[remote-instances] config sync apply failed`,e),Y.error(a(`settings.remoteInstances.page.sync.toast.failed`),{description:e instanceof Error?e.message:String(e)}),l(`review`)}}}),R=e=>c===`error`&&S!=null?e<S?`done`:e===S?`active`:`pending`:c===`review`||c===`applying`||e<o?`done`:e===o?`active`:`pending`;return(0,$.jsx)(Qt,{open:e,onOpenChange:i,children:(0,$.jsxs)(Yt,{className:`min-h-0 sm:max-w-2xl`,children:[(0,$.jsxs)(qt,{children:[(0,$.jsx)(Xt,{children:a(`settings.remoteInstances.page.sync.title`)}),(0,$.jsx)(Zt,{children:a(`settings.remoteInstances.page.sync.description`)})]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,$.jsx)(J,{type:`button`,size:`xs`,variant:u===`push`?`default`:`outline`,className:`!font-normal`,"aria-pressed":u===`push`,disabled:M||c===`comparing-remote`||c===`scanning-local`,onClick:()=>I(`push`),children:a(`settings.remoteInstances.page.sync.direction.push`)}),(0,$.jsx)(J,{type:`button`,size:`xs`,variant:u===`pull`?`default`:`outline`,className:`!font-normal`,"aria-pressed":u===`pull`,disabled:M||c===`comparing-remote`||c===`scanning-local`,onClick:()=>I(`pull`),children:a(`settings.remoteInstances.page.sync.direction.pull`)})]}),(0,$.jsxs)(`div`,{className:`space-y-2 rounded-lg border border-border/60 p-2`,children:[(0,$.jsx)(`div`,{className:`typography-meta text-muted-foreground`,children:a(`settings.remoteInstances.page.sync.scope.title`)}),T?null:(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground`,children:a(c===`scanning-local`||c===`comparing-remote`?`settings.remoteInstances.page.sync.step.scanLocal`:`settings.remoteInstances.page.sync.state.unavailable`)}),[{key:`config`,label:`config.json / opencode.json(c)`,index:0,kind:`fileGroups`},{key:`oh-slim`,label:`oh-my-opencode-slim.json(c)`,index:1,kind:`fileGroups`},{key:`oh-agent`,label:`oh-my-openagent.json(c)`,index:2,kind:`fileGroups`},{key:`agents-md`,label:`AGENTS.md`,index:0,kind:`singleFiles`},{key:`cursor-models`,label:`cursor-models.json`,index:1,kind:`singleFiles`},{key:`agents`,label:`agents/`,index:0,kind:`directories`},{key:`commands`,label:`commands/`,index:1,kind:`directories`},{key:`skills`,label:`skills/`,index:2,kind:`directories`},{key:`plugins`,label:`plugins/`,index:5,kind:`directories`}].filter(e=>m!=null&&e.index<m[e.kind]).map(e=>{let t=f[e.kind][e.index]!==!1;return(0,$.jsxs)(`label`,{className:`flex items-center gap-2 typography-meta`,children:[(0,$.jsx)(sn,{checked:t,disabled:M||!T,ariaLabel:e.label,onChange:t=>{if(!T)return;let n=[...f[e.kind]];n[e.index]=t;let r={...f,[e.kind]:n};p(r),c===`review`&&D(u,r)}}),(0,$.jsx)(`span`,{className:`font-mono`,children:e.label})]},e.key)}),(0,$.jsxs)(`label`,{className:`flex items-center gap-2 typography-meta`,children:[(0,$.jsx)(sn,{checked:f.agentsRoot,disabled:M||!T,ariaLabel:a(`settings.remoteInstances.page.sync.section.agentsRoot`),onChange:e=>{if(!T)return;let t={...f,agentsRoot:e};p(t),c===`review`&&D(u,t)}}),a(`settings.remoteInstances.page.sync.section.agentsRoot`)]}),(0,$.jsxs)(`label`,{className:`flex items-center gap-2 typography-meta`,children:[(0,$.jsx)(sn,{checked:f.authFile,disabled:M||!T,ariaLabel:a(`settings.remoteInstances.page.sync.section.authFile`),onChange:e=>{if(!T)return;let t={...f,authFile:e};p(t),c===`review`&&D(u,t)}}),a(`settings.remoteInstances.page.sync.section.authFile`)]})]}),(0,$.jsx)(`div`,{className:`space-y-2`,children:Pd.map((e,t)=>{let n=t+1,r=R(n);return(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[r===`done`?(0,$.jsx)(X,{name:`check`,className:`h-3.5 w-3.5 shrink-0 text-[var(--status-success)]`}):r===`active`?(0,$.jsx)(X,{name:`refresh`,className:`h-3.5 w-3.5 shrink-0 animate-spin text-muted-foreground`}):(0,$.jsx)(`span`,{className:`flex h-3.5 w-3.5 shrink-0 items-center justify-center rounded-full border border-border/60 typography-micro text-muted-foreground`,children:n}),(0,$.jsx)(`span`,{className:q(`typography-meta`,r===`pending`?`text-muted-foreground`:`text-foreground`),children:a(e)})]},e)})}),c===`error`?(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(`div`,{className:`typography-meta text-[var(--status-error)]`,children:a(`settings.remoteInstances.page.sync.state.error`,{message:b||``})}),(0,$.jsxs)(J,{type:`button`,variant:`outline`,size:`sm`,className:`!font-normal`,onClick:F,children:[(0,$.jsx)(X,{name:`refresh`,className:`h-3.5 w-3.5`}),a(`settings.remoteInstances.sidebar.actions.retry`)]})]}):null,N&&!j?(0,$.jsx)(`div`,{className:`typography-meta text-muted-foreground`,children:a(`settings.remoteInstances.page.sync.state.empty`)}):null,N&&j&&A?(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-col gap-3`,children:[(0,$.jsx)(`div`,{className:`overflow-hidden rounded-lg border border-border/60 bg-[var(--surface-elevated)]`,children:(0,$.jsx)(Sr,{fillContainer:!1,disableHorizontal:!0,outerClassName:`max-h-80`,className:`max-h-80`,children:(0,$.jsxs)(`div`,{className:`divide-y divide-border/60`,children:[A.files.map(e=>{let t=k.has(e.path);return(0,$.jsxs)(`div`,{className:`flex h-8 items-center gap-2 px-2`,children:[(0,$.jsx)(X,{name:`file-text`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1 truncate font-mono typography-micro text-foreground`,title:e.path,children:[(0,$.jsxs)(`span`,{className:`sr-only`,children:[a(`settings.remoteInstances.page.sync.section.files`),`: `]}),e.path]}),(0,$.jsx)(`span`,{className:`shrink-0 tabular-nums typography-micro text-muted-foreground`,children:Ad(e.bytes)}),(0,$.jsx)(`span`,{className:q(`shrink-0 typography-micro`,t?`text-[var(--status-warning)]`:`text-[var(--status-success)]`),children:a(t?`settings.remoteInstances.page.sync.status.overwrite`:`settings.remoteInstances.page.sync.status.add`)})]},`file:${e.path}`)}),A.directories.map(e=>{let t=k.has(e.path);return(0,$.jsxs)(`div`,{className:`flex h-8 items-center gap-2 px-2`,children:[(0,$.jsx)(X,{name:`folder-3-fill`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1 truncate font-mono typography-micro text-foreground`,title:e.path,children:[(0,$.jsxs)(`span`,{className:`sr-only`,children:[a(`settings.remoteInstances.page.sync.section.directories`),`: `]}),e.path]}),(0,$.jsxs)(`span`,{className:`shrink-0 tabular-nums typography-micro text-muted-foreground`,children:[Ad(e.bytes),` · `,e.fileCount]}),(0,$.jsx)(`span`,{className:q(`shrink-0 typography-micro`,t?`text-[var(--status-warning)]`:`text-[var(--status-success)]`),children:a(t?`settings.remoteInstances.page.sync.status.overwrite`:`settings.remoteInstances.page.sync.status.add`)})]},`dir:${e.path}`)}),A.authFile?(0,$.jsxs)(`div`,{className:`flex h-8 items-center gap-2 px-2`,children:[(0,$.jsx)(X,{name:`shield-keyhole`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1 truncate font-mono typography-micro text-foreground`,title:`~/.local/share/opencode/auth.json`,children:[(0,$.jsxs)(`span`,{className:`sr-only`,children:[a(`settings.remoteInstances.page.sync.section.authFile`),`: `]}),`~/.local/share/opencode/auth.json`]}),(0,$.jsx)(`span`,{className:`shrink-0 tabular-nums typography-micro text-muted-foreground`,children:Ad(A.authFile.bytes)}),(0,$.jsx)(`span`,{className:q(`shrink-0 typography-micro`,v?.remoteAuthFileExists?`text-[var(--status-warning)]`:`text-[var(--status-success)]`),children:v?.remoteAuthFileExists?a(`settings.remoteInstances.page.sync.status.overwrite`):a(`settings.remoteInstances.page.sync.status.add`)})]}):null,A.agentsRoot?(0,$.jsxs)(`div`,{className:`flex h-8 items-center gap-2 px-2`,children:[(0,$.jsx)(X,{name:`tools`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1 truncate font-mono typography-micro text-foreground`,title:`~/.agents`,children:[(0,$.jsxs)(`span`,{className:`sr-only`,children:[a(`settings.remoteInstances.page.sync.section.agentsRoot`),`: `]}),`~/.agents`]}),(0,$.jsxs)(`span`,{className:`shrink-0 tabular-nums typography-micro text-muted-foreground`,children:[Ad(A.agentsRoot.bytes),` · `,a(`settings.remoteInstances.page.sync.section.agentsRootCount`,{count:A.agentsRoot.fileCount})]}),(0,$.jsx)(`span`,{className:q(`shrink-0 typography-micro`,v?.remoteAgentsRootExists?`text-[var(--status-warning)]`:`text-[var(--status-success)]`),children:v?.remoteAgentsRootExists?a(`settings.remoteInstances.page.sync.status.overwrite`):a(`settings.remoteInstances.page.sync.status.add`)})]}):null]})})}),(0,$.jsxs)(`div`,{className:`space-y-1 typography-micro text-muted-foreground`,children:[P>0?(0,$.jsx)(`div`,{children:a(`settings.remoteInstances.page.sync.note.deletes`,{count:P})}):null,(0,$.jsx)(`div`,{children:a(`settings.remoteInstances.page.sync.note.backup`)}),(0,$.jsx)(`div`,{children:a(`settings.remoteInstances.page.sync.note.excluded`)})]})]}):null,(0,$.jsxs)(Jt,{className:`shrink-0`,children:[(0,$.jsx)(J,{type:`button`,variant:`outline`,size:`sm`,className:`!font-normal`,onClick:()=>i(!1),disabled:M,children:a(`settings.remoteInstances.page.sync.actions.cancel`)}),(0,$.jsxs)(J,{type:`button`,size:`sm`,className:`!font-normal`,onClick:()=>void L(),disabled:!j||M||c!==`review`,children:[(0,$.jsx)(X,{name:`refresh`,className:q(`h-3.5 w-3.5`,M?`animate-spin`:``)}),a(M?`settings.remoteInstances.page.sync.applying`:`settings.remoteInstances.page.sync.actions.syncNow`)]})]})]})})},Id=e=>{let t=(e instanceof Error?e.message:String(e)).toLowerCase();return t.includes(`address already in use`)||t.includes(`eaddrinuse`)||t.includes(`port already in use`)},Ld=()=>{if(typeof navigator>`u`)return;let e=(navigator.userAgent||``).toLowerCase();if(e.includes(`mac`))return`macos`;if(e.includes(`win`))return`windows`;if(e.includes(`linux`))return`linux`},Rd=e=>{switch((e||``).toLowerCase()){case`ios`:return`iOS`;case`android`:return`Android`;case`macos`:case`darwin`:return`macOS`;case`windows`:case`win32`:return`Windows`;case`linux`:return`Linux`;default:return null}},zd=e=>{switch(e){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`}},Bd=new Set([`config_resolved`,`auth_check`,`master_connecting`,`remote_probe`,`installing`,`updating`,`server_detecting`,`server_starting`,`forwarding`]),Vd=e=>!!(e&&Bd.has(e)),Hd=e=>e===`ready`?`bg-[var(--status-success)] animate-pulse`:e===`error`?`bg-[var(--status-error)] animate-pulse`:e===`degraded`||Vd(e)?`bg-[var(--status-warning)] animate-pulse`:`bg-muted-foreground/40`,Ud=e=>e.type===`dynamic`?`${e.localHost||`127.0.0.1`}:${e.localPort||0}`:e.type===`remote`?`${e.remoteHost||`127.0.0.1`}:${e.remotePort||0} -> ${e.localHost||`127.0.0.1`}:${e.localPort||0}`:`${e.localHost||`127.0.0.1`}:${e.localPort||0} -> ${e.remoteHost||`127.0.0.1`}:${e.remotePort||0}`,Wd=()=>({id:`forward-${Date.now()}-${Math.random().toString(16).slice(2)}`,enabled:!0,type:`local`,localHost:`127.0.0.1`,localPort:kd(),remoteHost:`127.0.0.1`,remotePort:80}),Gd=e=>e.trim().replace(/\*/g,`host`).replace(/\?/g,`x`)||`user@host`,Kd=e=>{let t=(0,Ii.c)(10),{itemId:n,label:r,description:i,action:a,children:o}=e,s;t[0]!==a||t[1]!==r?(s=a?(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3`,children:[(0,$.jsx)(`div`,{className:`min-w-0`,children:r}),(0,$.jsx)(`div`,{className:`shrink-0`,children:a})]}):r,t[0]=a,t[1]=r,t[2]=s):s=t[2];let c;t[3]===o?c=t[4]:(c=(0,$.jsx)(`div`,{className:`oc-settings-group-row`,children:o}),t[3]=o,t[4]=c);let l;return t[5]!==i||t[6]!==n||t[7]!==s||t[8]!==c?(l=(0,$.jsx)(vi,{itemId:n,className:`oc-settings-detail-group`,label:s,description:i,children:c}),t[5]=i,t[6]=n,t[7]=s,t[8]=c,t[9]=l):l=t[9],l},qd=e=>{switch(e){case`remote`:return`settings.remoteInstances.page.forwardTypeDescription.remote`;case`dynamic`:return`settings.remoteInstances.page.forwardTypeDescription.dynamic`;default:return`settings.remoteInstances.page.forwardTypeDescription.local`}},Jd=(e,t)=>{let n=(e||``).trim();return`${!n||n===`127.0.0.1`||n===`::1`?`localhost`:n}:${t||0}`},Yd=e=>{let t=(e||``).trim();return!t||t===`0.0.0.0`||t===`::`?`127.0.0.1`:t},Xd=e=>{let t=e.match(/^\[(\d{10,})\]\s*(?:\[([A-Z]+)\]\s*)?(.*)$/);if(!t)return e;let n=Number(t[1]);return`[${Number.isFinite(n)?new Date(n).toISOString():t[1]}] [${(t[2]||`INFO`).toUpperCase()}] ${t[3]||``}`},Zd=()=>{if(typeof window>`u`)return null;let e=c()||window.location.href;try{let t=Number(new URL(e).port||window.location.port);return Number.isFinite(t)&&t>0?t:null}catch{let e=Number(window.location.port);return Number.isFinite(e)&&e>0?e:null}},Qd=e=>{try{let t=new URL(e).hostname.toLowerCase();return t===`localhost`||t===`127.0.0.1`||t===`::1`||t===`[::1]`}catch{return!1}},$d=async()=>{let e=te(c())||window.location.origin;if(!u()||!_())return e;let t;try{t=await l(`/api/config/settings`,{method:`GET`,headers:{Accept:`application/json`}})}catch{return e}if(!t.ok||(await t.json().catch(()=>null))?.desktopLanAccessActive!==!0)return e;let n=await y(),r=Zd();return!n||!r?e:`http://${n}:${r}`},ef=e=>{let t=e.trim();if(t)try{window.location.assign(t)}catch{window.location.href=t}},tf=e=>{let t=e.sshCommand.trim(),n=e.nickname?.trim(),r=e.portForwards.map(e=>({...e,localHost:e.localHost?.trim()||`127.0.0.1`,localPort:typeof e.localPort==`number`?Math.max(1,Math.min(65535,Math.round(e.localPort))):void 0,remoteHost:e.remoteHost?.trim(),remotePort:typeof e.remotePort==`number`?Math.max(1,Math.min(65535,Math.round(e.remotePort))):void 0}));return{...e,sshCommand:t,...n?{nickname:n}:{nickname:void 0},connectionTimeoutSec:Math.max(5,Math.min(240,Math.round(e.connectionTimeoutSec||60))),localForward:{...e.localForward,bindHost:e.localForward.bindHost===`localhost`||e.localForward.bindHost===`0.0.0.0`?e.localForward.bindHost:`127.0.0.1`,preferredLocalPort:typeof e.localForward.preferredLocalPort==`number`?Math.max(1,Math.min(65535,Math.round(e.localForward.preferredLocalPort))):void 0},remoteOpenchamber:{...e.remoteOpenchamber,preferredPort:typeof e.remoteOpenchamber.preferredPort==`number`?Math.max(1,Math.min(65535,Math.round(e.remoteOpenchamber.preferredPort))):void 0},portForwards:r}},nf=()=>{let{t:e}=Me(),{clientAuth:t}=xr(),i=u(),o=li(e=>e.instances),l=li(e=>e.statusesById),d=li(e=>e.importCandidates),f=li(e=>e.isLoading),p=li(e=>e.isImportsLoading),m=li(e=>e.isSaving),h=li(e=>e.error),g=li(e=>e.load),_=li(e=>e.loadImports),v=li(e=>e.refreshStatuses),y=li(e=>e.upsertInstance),b=li(e=>e.createFromCommand),x=li(e=>e.removeInstance),S=li(e=>e.connect),C=li(e=>e.disconnect),w=li(e=>e.retry),T=K(e=>e.settingsRemoteInstancesSelectedId),E=K(e=>e.setSettingsRemoteInstancesSelectedId),D=Q.useMemo(()=>T&&o.find(e=>e.id===T)||null,[o,T]),[O,k]=Q.useState(null),[A,j]=Q.useState([]),[M,N]=Q.useState(!1),[F,I]=Q.useState(!1),[L,R]=Q.useState(null),[z,oe]=Q.useState([]),[se,ce]=Q.useState(!1),[le,ue]=Q.useState(null),[de,fe]=Q.useState(`ssh`),[pe,me]=Q.useState(null),[he,ge]=Q.useState(null),[_e,ve]=Q.useState(``),[ye,be]=Q.useState(!1),[xe,Se]=Q.useState({}),[Ce,we]=Q.useState(!1),[Te,Ee]=Q.useState(!1),[De,Oe]=Q.useState(()=>Date.now()),[ke,Ne]=Q.useState([]),[Pe,Fe]=Q.useState({}),[Ie,Le]=Q.useState(`local`),[Re,ze]=Q.useState(!1),[Be,Ve]=Q.useState(!1),[He,Ue]=Q.useState(0),We=or(),[Ge,Ke]=Q.useState(``),[qe,Je]=Q.useState(null),[Ye,Xe]=Q.useState(!1),[Ze,Qe]=Q.useState([]),[$e,et]=Q.useState([]),[tt,nt]=Q.useState(!1),[rt,it]=Q.useState(``),[at,ot]=Q.useState(null),[st,ct]=Q.useState(null),[lt,ut]=Q.useState(null),[dt,ft]=Q.useState(null),[pt,mt]=Q.useState(!1),[ht,gt]=Q.useState(!1),[_t,vt]=Q.useState(`configure`),[yt,bt]=Q.useState(!1),[xt,St]=Q.useState(`relay`),[Ct,wt]=Q.useState(!0),[Tt,Et]=Q.useState(Cd),[Dt,Ot]=Q.useState(null),[kt,At]=Q.useState(!1),jt=Q.useRef(null),[Mt,Nt]=Q.useState(null),Pt=Q.useMemo(()=>Ze.filter(e=>!!e.revokedAt).length,[Ze]),[Ft,It]=Q.useState(!1),[Lt,Rt]=Q.useState(`ssh user@example.com`),[zt,Bt]=Q.useState(``);Q.useEffect(()=>{g(),_()},[g,_]);let Vt=Q.useCallback(async()=>{ze(!0),Je(null);try{let e=await ne();Ne(e.hosts||[]),Le(e.defaultHostId||`local`)}catch(e){Je(e instanceof Error?e.message:String(e))}finally{ze(!1)}},[]);Q.useEffect(()=>{Vt()},[Vt]);let Ht=Object.values(l).filter(e=>e.phase===`ready`).map(e=>`${e.id}:${e.localUrl||``}`).sort().join(`|`);Q.useEffect(()=>{Ht&&Vt()},[Vt,Ht]);let Ut=Q.useCallback(async(e,t=Ie)=>{Ve(!0),Je(null);try{await U({hosts:e,defaultHostId:t,initialHostChoiceCompleted:!0}),Ne(e),Le(t)}catch(e){Je(e instanceof Error?e.message:String(e))}finally{Ve(!1)}},[Ie]),Wt=Q.useMemo(()=>new Set(o.map(e=>e.id)),[o]),Gt=Q.useMemo(()=>ke.filter(e=>ie(e,Wt)),[ke,Wt]),Kt=Ae(async()=>{let t=nd(Ge);if(!t){Je(e(`settings.remoteInstances.direct.error.invalidConnectLink`));return}let r=await B().catch(()=>``),i={method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({pairingId:t.pairingId,secret:t.secret,clientLabel:t.label||`OpenChamber Desktop`,clientKind:`desktop`,deviceName:`OpenChamber Desktop`,devicePlatform:Ld(),...r?{dedupeKey:`desktop:${r}`}:{}})},a=async e=>{if(!e.ok)return null;let t=await e.json().catch(()=>null);return(typeof t?.clientToken==`string`?t.clientToken.trim():``)||null},o=[...t.candidates].sort((e,t)=>(e.type===`relay`)-+(t.type===`relay`)),s=null;for(let e of o){if(e.type===`relay`){let t=n({relayUrl:e.relayUrl,serverId:e.serverId,hostEncPubJwk:e.hostEncPubJwk,...e.grant?{grant:e.grant}:{}});try{let n=await a(await t.fetch(`/api/client-auth/pairing/redeem`,i));if(n){s={kind:`relay`,relay:{relayUrl:e.relayUrl,serverId:e.serverId,hostEncPubJwk:e.hostEncPubJwk},token:n,tunnel:t},t.close();break}}catch{}t.close();continue}let t=te(e.url);if(t)try{let e=await a(await fetch(`${t}/api/client-auth/pairing/redeem`,i));if(e){s={kind:`direct`,url:t,token:e};break}}catch{}}if(!s){Je(e(`desktopHostSwitcher.error.invalidUrl`));return}let c=()=>P(),l=t.candidates.find(e=>e.type===`relay`),u=s.kind===`relay`?s.relay:l?{relayUrl:l.relayUrl,serverId:l.serverId,hostEncPubJwk:l.hostEncPubJwk}:void 0,d=t.candidates.filter(e=>e.type!==`relay`),f=d.map(e=>te(e.url)).find(e=>!!e),p=d.filter(e=>e.type===`lan`).map(e=>te(e.url)).find(e=>!!e),m=s.kind===`direct`?s.url:p||f||null,{token:h}=s,g=m||(u?V(u.serverId):null);if(!g){Je(e(`desktopHostSwitcher.error.invalidUrl`));return}let _={url:g,apiUrl:m||void 0,clientToken:h,source:re,...u?{relay:u}:{}},v=ke.find(e=>u?e.relay?.serverId===u.serverId&&e.relay?.relayUrl===u.relayUrl:!e.relay&&te(e.apiUrl||e.url)===g);if(v){let e=ke.map(e=>e.id===v.id?{...e,label:t.label||e.label,..._}:e);await Ut(e,Ie)}else await Ut([{id:c(),label:t.label||H(g),..._},...ke],Ie);Ke(``),Je(null),Xe(!1)}),$t=Q.useCallback(async e=>{let t=ke.filter(t=>t.id!==e);await Ut(t,Ie===e?`local`:Ie)},[Ie,ke,Ut]),en=Q.useCallback(async()=>{let t=Lt.trim();if(!t){Y.error(e(`settings.remoteInstances.page.toast.sshCommandRequired`));return}let n=`ssh-${Date.now()}-${Math.random().toString(16).slice(2)}`;try{await b(n,t,zt.trim()||void 0),E(n),It(!1),Rt(`ssh user@example.com`),Bt(``),Y.success(e(`settings.remoteInstances.page.toast.instanceCreated`))}catch(t){Y.error(e(`settings.remoteInstances.sidebar.toast.createFailed`),{description:t instanceof Error?t.message:String(t)})}},[b,E,Lt,zt,e]),nn=Q.useCallback(async e=>{await Ut(ke,e)},[ke,Ut]),on=Ae(async e=>{if(ae(e)||We)return;Je(null);let t=await Un({host:e,cachedProbe:Pe[e.id]||null});Fe(n=>({...n,[e.id]:t.status}))}),cn=Ae(async t=>{if(We)return;let n=t.nickname?.trim()||t.sshParsed?.destination||t.id,r=ke;try{let e=await ne();r=e.hosts||[],Ne(r),Le(e.defaultHostId||`local`)}catch(t){Y.error(e(`desktopHostSwitcher.toast.instanceUnreachable`,{host:n}),{description:t instanceof Error?t.message:String(t)});return}let i=r.find(e=>e.id===t.id)??null;if(!i||!W(i)||!i.clientToken){Y.error(e(`desktopHostSwitcher.toast.instanceUnreachable`,{host:n}));return}ae(i)||await Un({host:i})});Q.useEffect(()=>{if(i)return r(()=>{Ue(e=>e+1)})},[i]),Q.useEffect(()=>{if(!i||Gt.length===0)return;let e=!1;return Promise.all(Gt.map(async e=>{let t=async()=>{let t=await ee(e.relay,{clientToken:e.clientToken||null}).catch(()=>({status:`unreachable`,latencyMs:0}));return t.status===`ok`?{status:t.status,latencyMs:t.latencyMs,via:`relay`}:{status:t.status,latencyMs:t.latencyMs}};if(e.relay&&!e.apiUrl)return[e.id,await t()];let n=te(W(e));if(!n)return[e.id,e.relay?await t():{status:`unreachable`,latencyMs:0}];let r=await G(n,{clientToken:e.clientToken||null,requestHeaders:e.requestHeaders||null}).catch(()=>({status:`unreachable`,latencyMs:0}));if(r.status===`unreachable`&&e.relay){let n=await t();if(n.status===`ok`)return[e.id,n]}return[e.id,r]})).then(t=>{e||Fe(Object.fromEntries(t))}),()=>{e=!0}},[Gt,i]);let un=Q.useCallback(async e=>{if(t){e?.silent||nt(!0),e?.silent||ot(null);try{let[e,n]=await Promise.all([t.listClients(),t.listPendingPairings().catch(()=>null)]);Qe(e),n&&et(n)}catch(t){e?.silent||ot(t instanceof Error?t.message:String(t))}finally{e?.silent||nt(!1)}}},[t]),gn=Q.useRef(!1);Q.useEffect(()=>{if(!(!ht||_t!==`result`||!lt)){if($e.some(e=>e.id===lt)){gn.current=!0;return}gn.current&&(ut(null),gt(!1),Ze.some(e=>e.pairingId===lt)&&Y.success(e(`settings.remoteInstances.clientAuth.addDevice.connectedToast`)))}},[ht,_t,lt,$e,Ze,e]);let vn=Q.useCallback(async e=>{if(t)try{await t.cancelPairing(e),et(t=>t.filter(t=>t.id!==e)),await un({silent:!0})}catch(e){ot(e instanceof Error?e.message:String(e))}},[t,un]);Q.useEffect(()=>{if(!t)return;un();let e=window.setInterval(()=>{typeof document<`u`&&document.visibilityState!==`visible`||un({silent:!0})},5e3);return()=>window.clearInterval(e)},[t,un]);let yn=Q.useCallback(async()=>{let e=s()!==`local`;if(t?.getPairingTransports)try{let n=await t.getPairingTransports(),r=Td(n.relayUrl),i=Array.from(new Set([...Array.isArray(n.relayUrls)?n.relayUrls:[],...r?[r]:[]].map(e=>Td(e)).filter(e=>!!e)));return{localUrl:n.local,lanUrl:n.lan,relayAvailable:n.relayAvailable,relayUrl:r,relayUrls:n.relayAvailable?i:[],relayUrlLocked:n.relayUrlLocked===!0,remoteHost:e}}catch{}let n=Zd(),r=n?`http://127.0.0.1:${n}`:Qd(window.location.origin)?window.location.origin:null,i=null;try{let e=te(await $d());i=e&&!Qd(e)?e:null}catch{}return{localUrl:r,lanUrl:i,relayAvailable:!1,relayUrl:null,relayUrls:[],relayUrlLocked:!1,remoteHost:e}},[t]),bn=Ae(async()=>{ot(null),ct(null),ft(null),mt(!1),ut(null),Ot(null),vt(`configure`),wt(!0),gt(!0);let e=await yn();Nt(e),At(!1);let t=e.remoteHost?null:Ed();Et((e.relayUrlLocked||e.remoteHost?e.relayUrl:t||e.relayUrl)||`wss://relay.openchamber.dev/ws`),St(e.relayAvailable?`relay`:e.lanUrl?`lan`:`local`)}),xn=Ae(async()=>{if(!(!t?.createPairingSession||!Mt)){ot(null),bt(!0);try{let n=rt.trim()||void 0,r,i,a=!0;xt===`local`?(r=Mt.localUrl??void 0,i=!1):xt===`lan`?(r=Mt.lanUrl??void 0,i=Ct):Ct&&Mt.lanUrl?(r=Mt.lanUrl,i=!0):(a=!1,i=!0),Mt.relayAvailable||(i=!1);let o=i?Td(Tt):null;if(i&&!o){Ot(e(`settings.remoteInstances.clientAuth.addDevice.relayUrlInvalid`)),jt.current?.focus();return}Ot(null);let{pairing:s,server:c}=await t.createPairingSession({label:n,allowedClientKinds:[`mobile`,`desktop`],serverUrl:r,includeRelay:i,includeDirect:a,...o?{relayUrl:o}:{}}),l=$u({pairingId:s.id,secret:s.secret,label:n||c.label,fingerprint:s.fingerprint??void 0,expiresAt:s.expiresAt,candidates:c.candidates}),u=l.candidates.find(e=>e.type===`relay`);u&&(Et(u.relayUrl),Mt?.remoteHost!==!0&&Dd(u.relayUrl));let d=ed(l);ct(d),ft(await Vu.toDataURL(d,{width:1024,margin:2,errorCorrectionLevel:`L`})),mt(!1),gn.current=!1,ut(s.id),vt(`result`),await un({silent:!0})}catch(e){ot(e instanceof Error?e.message:String(e))}finally{bt(!1)}}}),Cn=Q.useCallback(()=>{st&&je(st).then(e=>{e.ok&&(mt(!0),window.setTimeout(()=>mt(!1),2e3))})},[st]),wn=Q.useCallback(async e=>{if(!t)return;let n=e.clientKind===`desktop-local`;ot(null);try{if(await t.revokeClient(e.id),n&&u()){let t=await ne();await U({hosts:t.hosts,defaultHostId:t.defaultHostId,initialHostChoiceCompleted:t.initialHostChoiceCompleted,localClientToken:null}),Qe(t=>t.map(t=>t.id===e.id?{...t,revokedAt:new Date().toISOString()}:t)),a({apiBaseUrl:c(),clientToken:null,runtimeKey:`local`});return}await un()}catch(e){ot(e instanceof Error?e.message:String(e))}},[t,un]),Tn=Q.useCallback(async()=>{if(t){ot(null);try{await t.purgeRevokedClients(),await un()}catch(e){ot(e instanceof Error?e.message:String(e))}}},[t,un]);Q.useEffect(()=>{k(D)},[D]),Q.useEffect(()=>{let e=!1;return!T||D?.remoteOpenchamber?.mode!==`managed`?(j([]),()=>{e=!0}):(sr(T).then(t=>{e||j(t.slice(-5).reverse())}).catch(()=>{e||j([])}),()=>{e=!0})},[T,D?.remoteOpenchamber?.mode,se]),Q.useEffect(()=>{if(!T)return;let e=window.setInterval(()=>{typeof document<`u`&&document.visibilityState!==`visible`||v()},2e3);return()=>{window.clearInterval(e)}},[v,T]),Q.useEffect(()=>{let e=null,t=Date.now(),n=()=>{let r=Date.now();r-t>=1e3&&(Oe(r),t=r),e=requestAnimationFrame(n)};(typeof document>`u`||document.visibilityState===`visible`)&&(e=requestAnimationFrame(n));let r=()=>{document.visibilityState===`visible`&&e===null?e=requestAnimationFrame(n):document.visibilityState!==`visible`&&e!==null&&(cancelAnimationFrame(e),e=null)};return document.addEventListener(`visibilitychange`,r),()=>{document.removeEventListener(`visibilitychange`,r),e!==null&&cancelAnimationFrame(e)}},[]);let En=T?l[T]:null,Dn=En?.phase,On=Dn===`ready`,kn=Dn===`degraded`,An=Vd(Dn),jn=On||An||kn,Mn=En?Math.max(0,De-En.updatedAtMs):0,Nn=kn&&Mn>12e3,Fn=Q.useMemo(()=>!O||!D?!1:JSON.stringify(O)!==JSON.stringify(D),[O,D]),Z=Q.useCallback(e=>{k(t=>t&&e(t))},[]),In=Q.useCallback(async()=>{if(!O)return;let t=tf(O);if(!t.sshCommand.trim()){Y.error(e(`settings.remoteInstances.page.toast.sshCommandRequired`));return}if(!(t.localForward.bindHost===`0.0.0.0`&&!window.confirm(e(`settings.remoteInstances.page.confirm.bindAllInterfaces`)))){if(t.auth.sshPassword?.enabled&&t.auth.sshPassword.value?.trim()&&t.auth.sshPassword.store!==`settings`){let n=window.confirm(e(`settings.remoteInstances.page.confirm.storeSshPasswordPlaintext`));t.auth.sshPassword.store=n?`settings`:`never`,n||(t.auth.sshPassword.value=void 0)}if(t.auth.openchamberPassword?.enabled&&t.auth.openchamberPassword.value?.trim()&&t.auth.openchamberPassword.store!==`settings`){let n=window.confirm(e(`settings.remoteInstances.page.confirm.storeUiPasswordPlaintext`));t.auth.openchamberPassword.store=n?`settings`:`never`,n||(t.auth.openchamberPassword.value=void 0)}try{await y(t),Y.success(e(`settings.remoteInstances.page.toast.instanceSaved`))}catch(t){Y.error(e(`settings.remoteInstances.page.toast.saveFailed`),{description:t instanceof Error?t.message:String(t)})}}},[O,e,y]),Ln=Q.useCallback(async(t,n)=>{let r=`ssh-${Date.now()}-${Math.random().toString(16).slice(2)}`;try{return await b(r,`ssh ${n}`,t),E(r),Y.success(e(`settings.remoteInstances.page.toast.instanceCreated`)),!0}catch(t){return Y.error(e(`settings.remoteInstances.sidebar.toast.createFailed`),{description:t instanceof Error?t.message:String(t)}),!1}},[b,E,e]),Rn=Q.useCallback(()=>{ye||(ge(null),ve(``))},[ye]),Bn=Q.useCallback((e,t)=>{if(t){ge(e),ve(Gd(e));return}Ln(e,e)},[Ln]),Hn=Q.useCallback(async()=>{let t=he,n=_e.trim();if(t){if(!n){Y.error(e(`settings.remoteInstances.page.toast.destinationRequired`));return}be(!0);try{await Ln(t,n)&&(ge(null),ve(``))}finally{be(!1)}}},[Ln,_e,he,e]),Wn=Q.useCallback(async()=>{if(D)try{await S(D.id);return}catch(t){if(!Id(t)||!window.confirm(e(`settings.remoteInstances.sidebar.confirm.localPortInUseRetry`)))throw t;let n={...D,localForward:{...D.localForward,preferredLocalPort:kd()}};await y(n),await S(n.id),Y.success(e(`settings.remoteInstances.sidebar.toast.retriedWithRandomPort`))}},[S,D,e,y]),Gn=Q.useCallback(async e=>(await Vn(e,600)).map(e=>Xd(e)),[]),Kn=Q.useCallback(async()=>{if(O){N(!0),I(!0),R(null);try{let e=await Gn(O.id);oe(e)}catch(e){oe([]),R(e instanceof Error?e.message:String(e))}finally{I(!1)}}},[O,Gn]);Q.useEffect(()=>{if(!M||!O)return;let e=!1,t=async()=>{try{let t=await Gn(O.id);e||(oe(t),R(null))}catch(t){e||R(t instanceof Error?t.message:String(t))}};t();let n=window.setInterval(()=>{typeof document<`u`&&document.visibilityState!==`visible`||t()},1e3);return()=>{e=!0,window.clearInterval(n)}},[O,M,Gn]);let qn=Q.useMemo(()=>z.join(`
|
|
23
|
+
`),[z]),Jn=Q.useCallback(()=>{if(!qn.trim()){Y.error(e(`settings.remoteInstances.page.toast.noLogsToCopy`));return}je(qn).then(t=>{t.ok&&Y.success(e(`settings.remoteInstances.page.toast.logsCopied`))})},[qn,e]),Yn=Q.useCallback(async()=>{if(O)try{await Pn(O.id),oe([]),Y.success(e(`settings.remoteInstances.page.toast.logsCleared`))}catch(t){Y.error(e(`settings.remoteInstances.page.toast.clearLogsFailed`),{description:t instanceof Error?t.message:String(t)})}},[O,e]),Xn=Q.useCallback(async()=>{if(!En?.localUrl){Y.error(e(`settings.remoteInstances.page.toast.instanceUrlUnavailable`));return}let t=En.localUrl.trim();if(!t){Y.error(e(`settings.remoteInstances.page.toast.instanceUrlUnavailable`));return}ef(t)},[En?.localUrl,e]),Zn=Q.useCallback((e,t=`ssh`,n=null)=>{ue(e),fe(t),me(n),ce(!0)},[]),Qn=Q.useCallback(()=>{if(!O)return;let t=jn,n=O.id;we(!0),(t?C(n):Wn()).catch(n=>{let r=t?On?`settings.remoteInstances.page.toast.disconnectFailed`:`settings.remoteInstances.page.toast.cancelConnectionFailed`:`settings.remoteInstances.page.toast.connectFailed`,i=En?.detail||(n instanceof Error?n.message:String(n)),a=zn(En?.errorCode,i);Y.error(e(r),{description:t?n instanceof Error?n.message:String(n):_n(e(Sn(a)),a,i)})}).finally(()=>{we(!1)})},[jn,Wn,C,O,On,En,e]),$n=Q.useCallback(()=>{O&&(An||(Ee(!0),(kn?C(O.id).then(()=>Wn()):w(O.id)).catch(t=>{let n=En?.detail||(t instanceof Error?t.message:String(t)),r=zn(En?.errorCode,n);Y.error(e(`settings.remoteInstances.page.toast.retryFailed`),{description:_n(e(Sn(r)),r,n)})}).finally(()=>{Ee(!1)})))},[Wn,C,O,An,kn,w,En,e]),er=e(An?`settings.remoteInstances.page.actions.connecting`:kn?Nn?`settings.remoteInstances.page.actions.reconnectNow`:`settings.remoteInstances.page.actions.reconnecting`:`settings.remoteInstances.sidebar.actions.retry`),tr=!Ce&&!Te&&(Dn===`error`||Dn===`idle`||!Dn||kn&&Nn)&&!An,nr=e(On?`settings.remoteInstances.sidebar.actions.disconnect`:jn?`settings.remoteInstances.page.actions.cancel`:`settings.remoteInstances.sidebar.actions.connect`);if(!O)return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(El,{children:[t?(0,$.jsx)(Kd,{itemId:`remote-instances.client-auth`,label:e(`settings.remoteInstances.clientAuth.title`),description:e(`settings.remoteInstances.clientAuth.description`),children:(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(`div`,{children:(0,$.jsxs)(J,{type:`button`,size:`xs`,className:`!font-normal`,onClick:()=>void bn(),children:[(0,$.jsx)(X,{name:`add`,className:`h-3.5 w-3.5`}),e(`settings.remoteInstances.clientAuth.actions.addDevice`)]})}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[Pt>0?(0,$.jsx)(`div`,{className:`flex justify-end`,children:(0,$.jsx)(J,{type:`button`,variant:`ghost`,size:`xs`,className:`!font-normal`,onClick:()=>void Tn(),children:e(`settings.remoteInstances.clientAuth.actions.clearRevoked`)})}):null,tt&&Ze.length===0&&$e.length===0?(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:e(`settings.remoteInstances.clientAuth.state.loading`)}):Ze.length===0&&$e.length===0?(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:e(`settings.remoteInstances.clientAuth.state.empty`)}):(0,$.jsxs)($.Fragment,{children:[$e.map(t=>(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 py-1.5`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full bg-[var(--status-warning)] animate-pulse`}),(0,$.jsx)(`p`,{className:`typography-ui-label text-foreground truncate`,children:t.label||e(`settings.remoteInstances.clientAuth.field.labelPlaceholder`)}),t.usesRelay?(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground bg-muted px-1 rounded shrink-0 leading-none pb-px border border-border/50`,children:e(`settings.remoteInstances.clientAuth.state.viaRelay`)}):null]}),(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground truncate`,children:e(`settings.remoteInstances.clientAuth.state.pending`)})]}),(0,$.jsx)(J,{type:`button`,variant:`ghost`,size:`xs`,className:`!font-normal`,onClick:()=>void vn(t.id),children:e(`settings.common.actions.cancel`)})]},`pending-${t.id}`)),Ze.map(t=>{let n=t.clientKind===`desktop-local`,r=t.lastUsedAt?Date.parse(t.lastUsedAt):NaN,i=!t.revokedAt&&(n||Number.isFinite(r)&&Date.now()-r<9e4),a=t.revokedAt?e(`settings.remoteInstances.clientAuth.state.revoked`):i?t.lastTransport===`relay`&&!n?e(`settings.remoteInstances.clientAuth.state.connectedRelay`):e(`settings.remoteInstances.clientAuth.state.connectedDirect`):t.lastUsedAt?e(`settings.remoteInstances.clientAuth.lastUsed`,{date:t.lastUsedAt}):e(`settings.remoteInstances.clientAuth.neverUsed`);return(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 py-1.5`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(`span`,{className:q(`h-2 w-2 shrink-0 rounded-full`,t.revokedAt?`bg-muted-foreground/20`:i?`bg-[var(--status-success)]`:`bg-muted-foreground/30`)}),(0,$.jsx)(`p`,{className:`typography-ui-label text-foreground truncate`,children:t.label}),Rd(t.devicePlatform)?(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground bg-muted px-1 rounded shrink-0 leading-none pb-px border border-border/50`,children:Rd(t.devicePlatform)}):null,n?(0,$.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:e(`settings.remoteInstances.clientAuth.state.thisDevice`)}):null]}),(0,$.jsx)(`p`,{className:q(`typography-micro truncate`,i&&!t.revokedAt?`text-[var(--status-success)]`:`text-muted-foreground`),children:a})]}),(0,$.jsx)(J,{type:`button`,variant:`ghost`,size:`xs`,className:`!font-normal`,onClick:()=>void wn(t),disabled:!!t.revokedAt,children:e(`settings.remoteInstances.clientAuth.actions.revoke`)})]},t.id)})]})]}),at?(0,$.jsx)(`p`,{className:`typography-meta text-[var(--status-error)]`,children:at}):null]})}):null,i?(0,$.jsx)(Kd,{itemId:`remote-instances.instances`,label:e(`settings.remoteInstances.sidebar.title`),description:e(`settings.remoteInstances.sidebar.description`),action:(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 pt-0.5`,children:[(0,$.jsx)(J,{type:`button`,size:`xs`,className:`!font-normal`,onClick:()=>Xe(!0),disabled:Be,children:e(`settings.remoteInstances.direct.import.action`)}),(0,$.jsxs)(J,{type:`button`,size:`xs`,className:`!font-normal`,onClick:()=>It(!0),children:[(0,$.jsx)(X,{name:`add`,className:`h-3.5 w-3.5`}),e(`settings.remoteInstances.sidebar.actions.addSshInstance`)]})]}),children:(0,$.jsxs)(`div`,{className:`space-y-1`,children:[Re||f?(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:e(`settings.remoteInstances.direct.state.loading`)}):Gt.length===0&&o.length===0?(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:e(`settings.remoteInstances.sidebar.empty`)}):(0,$.jsxs)($.Fragment,{children:[Gt.map(t=>{let n=Pe[t.id],r=n?n.status===`ok`?`desktopHostSwitcher.status.connected`:n.status===`auth`?`desktopHostSwitcher.status.authRequired`:n.status===`update-recommended`?`desktopHostSwitcher.status.updateRecommended`:n.status===`incompatible`?`desktopHostSwitcher.status.incompatible`:n.status===`wrong-service`?`desktopHostSwitcher.status.wrongService`:`desktopHostSwitcher.status.unreachable`:`desktopHostSwitcher.status.checking`,i=n?.status===`ok`,a=ae(t),o=a||We||Be;return(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 py-1.5`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(`span`,{className:q(`h-2 w-2 shrink-0 rounded-full`,n?i||a?`bg-[var(--status-success)]`:`bg-[var(--status-error)]`:`bg-muted-foreground/30 animate-pulse`)}),(0,$.jsx)(`p`,{className:`typography-ui-label text-foreground truncate`,children:H(t.label)}),(0,$.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:e(`settings.remoteInstances.channel.link`)}),a?(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground shrink-0`,children:e(`desktopHostSwitcher.header.current`)}):null,Ie===t.id?(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground shrink-0`,children:e(`desktopHostSwitcher.header.default`)}):null,(0,$.jsxs)(`span`,{className:q(`typography-micro shrink-0`,i||a?`text-[var(--status-success)]`:`text-muted-foreground`),children:[e(r),i&&typeof n?.latencyMs==`number`?e(`desktopHostSwitcher.status.ping`,{ms:Math.max(0,Math.round(n.latencyMs))}):``]})]}),(0,$.jsx)(`p`,{className:q(`typography-micro text-muted-foreground truncate`,t.apiUrl&&`font-mono`),children:t.relay&&!t.apiUrl?e(`mobile.connect.relay.badge`):H(t.apiUrl||t.url)})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,$.jsxs)(J,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>void on(t),disabled:o,"aria-label":e(`desktopHostSwitcher.actions.switchToAria`,{instance:H(t.label)}),children:[(0,$.jsx)(X,{name:`arrow-left-right`,className:`h-3.5 w-3.5`}),e(a?`desktopHostSwitcher.header.current`:`desktopHostSwitcher.actions.switchInstance`)]}),(0,$.jsx)(J,{type:`button`,variant:`ghost`,size:`xs`,className:`!font-normal`,onClick:()=>void nn(t.id),disabled:Be||Ie===t.id,"aria-label":e(`desktopHostSwitcher.actions.setAsDefaultAria`),children:Ie===t.id?(0,$.jsx)(X,{name:`star-fill`,className:`h-3.5 w-3.5`}):(0,$.jsx)(X,{name:`star`,className:`h-3.5 w-3.5`})}),(()=>{let n=W(t),r=!!n&&!n.startsWith(`relay://`)&&!t.relay;return t.relay?.serverId&&t.relay?.relayUrl&&t.relay?.hostEncPubJwk&&t.clientToken&&t.relay?(0,$.jsxs)(J,{type:`button`,variant:`ghost`,size:`xs`,className:`!font-normal`,onClick:()=>Zn(t.id,`relay`,t),"aria-label":e(`settings.remoteInstances.page.sync.title`),children:[(0,$.jsx)(X,{name:`refresh`,className:`h-3.5 w-3.5`}),e(`settings.remoteInstances.page.sync.actions.syncNow`)]}):r?(0,$.jsxs)(J,{type:`button`,variant:`ghost`,size:`xs`,className:`!font-normal`,onClick:()=>Zn(t.id,`direct`),"aria-label":e(`settings.remoteInstances.page.sync.title`),children:[(0,$.jsx)(X,{name:`refresh`,className:`h-3.5 w-3.5`}),e(`settings.remoteInstances.page.sync.actions.syncNow`)]}):null})(),(0,$.jsxs)(J,{type:`button`,variant:`ghost`,size:`xs`,className:`!font-normal`,onClick:()=>void $t(t.id),disabled:Be||We,children:[(0,$.jsx)(X,{name:`delete-bin`,className:`h-3.5 w-3.5`}),e(`settings.common.actions.delete`)]})]})]},`link:${t.id}`)}),o.map(t=>{let n=l[t.id],r=t.nickname?.trim()||t.sshParsed?.destination||t.id,i=n?.phase,a=i===`ready`,o=ke.find(e=>e.id===t.id),s=ae({id:t.id,label:r,url:n?.localUrl||o?.url||``}),c=(0,$.jsxs)(J,{type:`button`,variant:`ghost`,size:`xs`,className:`!font-normal`,onClick:()=>void cn(t),disabled:s||We||!a,"aria-label":e(`desktopHostSwitcher.actions.switchToAria`,{instance:r}),children:[(0,$.jsx)(X,{name:`arrow-left-right`,className:`h-3.5 w-3.5`}),e(s?`desktopHostSwitcher.header.current`:`desktopHostSwitcher.actions.switchInstance`)]});return(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 py-1.5`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full ${Hd(i)}`}),(0,$.jsx)(`p`,{className:`typography-ui-label text-foreground truncate`,children:r}),(0,$.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:e(`settings.remoteInstances.channel.ssh`)}),s?(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground shrink-0`,children:e(`desktopHostSwitcher.header.current`)}):null]}),(0,$.jsxs)(`p`,{className:`typography-micro text-muted-foreground truncate`,children:[e(zd(i)),n?.localUrl?` · ${n.localUrl}`:``]})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,$.jsxs)(J,{type:`button`,variant:`ghost`,size:`xs`,className:`!font-normal`,onClick:()=>{(a?C(t.id):S(t.id)).catch(t=>{let r=n?.detail||(t instanceof Error?t.message:String(t)),i=zn(n?.errorCode,r);Y.error(e(a?`settings.remoteInstances.sidebar.toast.disconnectFailed`:`settings.remoteInstances.sidebar.toast.connectFailed`),{description:a?t instanceof Error?t.message:String(t):_n(e(Sn(i)),i,r)})})},children:[a?(0,$.jsx)(X,{name:`stop`,className:`h-3.5 w-3.5`}):(0,$.jsx)(X,{name:`plug-2`,className:`h-3.5 w-3.5`}),e(a?`settings.remoteInstances.sidebar.actions.disconnect`:`settings.remoteInstances.sidebar.actions.connect`)]}),a?c:(0,$.jsxs)(hn,{children:[(0,$.jsx)(pn,{asChild:!0,children:(0,$.jsx)(`span`,{className:`inline-flex`,children:c})}),(0,$.jsx)(mn,{sideOffset:8,className:`max-w-xs`,children:e(`settings.remoteInstances.sidebar.actions.switchInstanceDisabled`)})]}),a&&t.remoteOpenchamber?.mode!==`external`?(0,$.jsxs)(J,{type:`button`,variant:`ghost`,size:`xs`,className:`!font-normal`,onClick:()=>Zn(t.id),children:[(0,$.jsx)(X,{name:`refresh`,className:`h-3.5 w-3.5`}),e(`settings.remoteInstances.sidebar.actions.syncConfig`)]}):(0,$.jsxs)(hn,{children:[(0,$.jsx)(pn,{asChild:!0,children:(0,$.jsx)(`span`,{className:`inline-flex`,children:(0,$.jsxs)(J,{type:`button`,variant:`ghost`,size:`xs`,className:`!font-normal`,disabled:!0,"aria-label":e(`settings.remoteInstances.sidebar.actions.syncConfigDisabled`),children:[(0,$.jsx)(X,{name:`refresh`,className:`h-3.5 w-3.5`}),e(`settings.remoteInstances.sidebar.actions.syncConfig`)]})})}),(0,$.jsx)(mn,{sideOffset:8,className:`max-w-xs`,children:e(`settings.remoteInstances.sidebar.actions.syncConfigDisabled`)})]}),(0,$.jsxs)(J,{type:`button`,variant:`ghost`,size:`xs`,className:`!font-normal`,onClick:()=>E(t.id),children:[(0,$.jsx)(X,{name:`pencil`,className:`h-3.5 w-3.5`}),e(`desktopHostSwitcher.actions.edit`)]})]})]},`ssh:${t.id}`)})]}),qe?(0,$.jsx)(`p`,{className:`typography-meta text-[var(--status-error)]`,children:qe}):null]})}):null,i?(0,$.jsx)(Qt,{open:Ye,onOpenChange:Xe,children:(0,$.jsxs)(Yt,{className:`sm:max-w-lg`,children:[(0,$.jsxs)(qt,{children:[(0,$.jsx)(Xt,{children:e(`settings.remoteInstances.direct.import.action`)}),(0,$.jsx)(Zt,{children:e(`settings.remoteInstances.direct.import.description`)})]}),(0,$.jsxs)(`form`,{className:`space-y-3`,onSubmit:e=>{e.preventDefault(),Kt()},children:[(0,$.jsx)(fn,{className:`h-8`,value:Ge,onChange:e=>Ke(e.target.value),placeholder:e(`settings.remoteInstances.direct.import.placeholder`),disabled:Be,autoFocus:!0}),(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(J,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>Xe(!1),disabled:Be,children:e(`settings.common.actions.cancel`)}),(0,$.jsx)(J,{type:`submit`,size:`xs`,className:`!font-normal`,disabled:Be||!Ge.trim(),children:e(`settings.remoteInstances.direct.import.action`)})]})]})]})}):null,(0,$.jsx)(Qt,{open:ht,onOpenChange:gt,children:(0,$.jsxs)(Yt,{className:_t===`result`?`sm:max-w-lg`:`sm:max-w-md`,children:[(0,$.jsxs)(qt,{children:[(0,$.jsx)(Xt,{children:e(_t===`result`?`settings.remoteInstances.clientAuth.qrDialogTitle`:`settings.remoteInstances.clientAuth.actions.addDevice`)}),(0,$.jsx)(Zt,{children:e(_t===`result`?`settings.remoteInstances.clientAuth.qrScanHint`:`settings.remoteInstances.clientAuth.addDevice.subtitle`)})]}),_t===`configure`?(0,$.jsxs)(`form`,{className:`space-y-4`,onSubmit:e=>{e.preventDefault(),xn()},children:[(0,$.jsxs)(`label`,{className:`block space-y-1.5`,children:[(0,$.jsx)(fn,{className:`h-8`,value:rt,onChange:e=>it(e.target.value),placeholder:e(`settings.remoteInstances.clientAuth.field.labelPlaceholder`),"aria-describedby":`add-device-instance-name-hint`,autoFocus:!0}),(0,$.jsx)(`span`,{id:`add-device-instance-name-hint`,className:`block typography-meta text-muted-foreground`,children:e(`settings.remoteInstances.clientAuth.field.labelHint`)})]}),(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(`p`,{className:`typography-ui-label text-foreground`,children:e(`settings.remoteInstances.clientAuth.addDevice.transportLabel`)}),(0,$.jsx)(`div`,{role:`radiogroup`,"aria-label":e(`settings.remoteInstances.clientAuth.addDevice.transportLabel`),className:`space-y-1.5`,children:[{key:`relay`,label:e(`settings.remoteInstances.clientAuth.addDevice.transport.relay`),hint:e(`settings.remoteInstances.clientAuth.addDevice.transport.relayHint`),available:!!Mt?.relayAvailable},{key:`lan`,label:e(`settings.remoteInstances.clientAuth.addDevice.transport.lan`),hint:e(`settings.remoteInstances.clientAuth.addDevice.transport.lanHint`),available:!!Mt?.lanUrl},{key:`local`,label:e(`settings.remoteInstances.clientAuth.addDevice.transport.local`),hint:e(`settings.remoteInstances.clientAuth.addDevice.transport.localHint`),available:!!Mt?.localUrl}].map(e=>{let t=xt===e.key;return(0,$.jsxs)(`div`,{className:q(`flex items-start gap-2 py-0.5`,e.available?`cursor-pointer`:`opacity-45`),onClick:()=>{e.available&&St(e.key)},role:`presentation`,children:[(0,$.jsx)(Ks,{checked:t,disabled:!e.available,onChange:()=>St(e.key),ariaLabel:e.label,className:`mt-0.5`}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`p`,{className:q(`typography-ui-label font-normal`,t?`text-foreground`:`text-foreground/70`),children:e.label}),(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:e.hint})]})]},e.key)})}),xt===`lan`?(0,$.jsxs)(`label`,{className:`flex w-fit cursor-pointer items-center gap-2 pt-1`,children:[(0,$.jsx)(sn,{checked:Ct,onChange:wt,ariaLabel:e(`settings.remoteInstances.clientAuth.addDevice.fallback.relay`)}),(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:e(`settings.remoteInstances.clientAuth.addDevice.fallback.relay`)})]}):null,xt===`relay`&&Mt?.lanUrl?(0,$.jsxs)(`label`,{className:`flex w-fit cursor-pointer items-center gap-2 pt-1`,children:[(0,$.jsx)(sn,{checked:Ct,onChange:wt,ariaLabel:e(`settings.remoteInstances.clientAuth.addDevice.fallback.preferLocal`)}),(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:e(`settings.remoteInstances.clientAuth.addDevice.fallback.preferLocal`)})]}):null,xt===`relay`||xt===`lan`&&Ct?(()=>{let t=Array.from(new Set([...Mt?.relayUrls??[],...Mt?.relayUrl?[Mt.relayUrl]:[]])),n=t.length>1,r=Mt?.relayUrlLocked!==!0&&Mt?.remoteHost!==!0,i=n&&!kt;return(0,$.jsxs)(`label`,{className:`block space-y-1.5 pt-2`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e(`settings.remoteInstances.clientAuth.addDevice.relayUrlLabel`)}),i?(0,$.jsxs)(ln,{value:t.includes(Tt)?Tt:t[0],onValueChange:e=>{if(e===`__custom__`){At(!0);return}Et(e),Ot(null)},children:[(0,$.jsx)(rn,{className:`h-8 w-full font-mono`,"aria-label":e(`settings.remoteInstances.clientAuth.addDevice.relayUrlLabel`),children:(0,$.jsx)(dn,{})}),(0,$.jsxs)(an,{children:[t.map(e=>(0,$.jsx)(tn,{value:e,className:`font-mono`,children:(0,$.jsx)(`span`,{className:`block max-w-[420px] truncate`,children:e})},e)),r?(0,$.jsx)(tn,{value:`__custom__`,children:e(`settings.remoteInstances.clientAuth.addDevice.relayUrlCustomOption`)}):null]})]}):(0,$.jsx)(fn,{ref:jt,className:`h-8 font-mono`,value:Tt,onChange:e=>{Et(e.target.value),Ot(null)},placeholder:Cd,readOnly:Mt?.relayUrlLocked===!0||Mt?.remoteHost===!0,"aria-readonly":Mt?.relayUrlLocked===!0||Mt?.remoteHost===!0||void 0,"aria-invalid":!!Dt||void 0,"aria-describedby":Dt?`add-device-relay-url-hint add-device-relay-url-error`:`add-device-relay-url-hint`,spellCheck:!1,autoCapitalize:`none`,autoCorrect:`off`}),(0,$.jsx)(`span`,{id:`add-device-relay-url-hint`,className:`block typography-meta text-muted-foreground`,children:Mt?.relayUrlLocked?e(`settings.remoteInstances.clientAuth.addDevice.relayUrlLockedHint`):Mt?.remoteHost?e(`settings.remoteInstances.clientAuth.addDevice.relayUrlRemoteHostHint`):(0,$.jsxs)($.Fragment,{children:[e(`settings.remoteInstances.clientAuth.addDevice.relayUrlHint`),` `,(0,$.jsx)(`a`,{href:Od,target:`_blank`,rel:`noopener noreferrer`,className:`underline underline-offset-2 hover:text-foreground`,onClick:e=>{e.preventDefault(),kr(Od)},children:e(`settings.remoteInstances.clientAuth.addDevice.relayUrlDeployLink`)})]})}),Dt?(0,$.jsx)(`span`,{id:`add-device-relay-url-error`,role:`alert`,"aria-live":`polite`,className:`block typography-meta text-[var(--status-error)]`,children:Dt}):null]})})():null]}),at?(0,$.jsx)(`p`,{className:`typography-meta text-[var(--status-error)]`,children:at}):null,(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(J,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>gt(!1),disabled:yt,children:e(`settings.common.actions.cancel`)}),(0,$.jsx)(J,{type:`submit`,size:`xs`,className:`!font-normal`,disabled:yt||!Mt,children:e(`settings.remoteInstances.clientAuth.addDevice.create`)})]})]}):(0,$.jsxs)(`div`,{className:`space-y-3`,children:[dt?(0,$.jsx)(`div`,{className:`flex justify-center`,children:(0,$.jsx)(`img`,{src:dt,alt:e(`settings.remoteInstances.clientAuth.qrAlt`),className:`w-full max-w-[420px] rounded-md bg-white p-4`})}):null,st?(0,$.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border border-[var(--interactive-border)] p-2`,children:[(0,$.jsx)(`code`,{className:`min-w-0 flex-1 truncate typography-code text-muted-foreground`,children:st}),(0,$.jsxs)(J,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal shrink-0`,onClick:Cn,children:[(0,$.jsx)(X,{name:pt?`check`:`file-copy`,className:q(`h-3.5 w-3.5`,pt&&`text-[var(--status-success)]`)}),e(pt?`settings.remoteInstances.clientAuth.actions.copied`:`settings.common.actions.copyAll`)]})]}):null,(0,$.jsx)(`div`,{className:`flex justify-end`,children:(0,$.jsx)(J,{type:`button`,size:`xs`,className:`!font-normal`,onClick:()=>gt(!1),children:e(`settings.remoteInstances.clientAuth.addDevice.done`)})})]})]})}),i?(0,$.jsx)(Qt,{open:Ft,onOpenChange:It,children:(0,$.jsxs)(Yt,{className:`sm:max-w-lg`,children:[(0,$.jsxs)(qt,{children:[(0,$.jsx)(Xt,{children:e(`settings.remoteInstances.sidebar.actions.addSshInstance`)}),(0,$.jsx)(Zt,{children:e(`settings.remoteInstances.page.section.instanceDescription`)})]}),(0,$.jsxs)(`form`,{className:`space-y-3`,onSubmit:e=>{e.preventDefault(),en()},children:[(0,$.jsx)(fn,{className:`h-8`,value:zt,onChange:e=>Bt(e.target.value),placeholder:e(`settings.remoteInstances.page.field.nicknamePlaceholder`),disabled:m}),(0,$.jsx)(fn,{className:`h-8`,value:Lt,onChange:e=>Rt(e.target.value),placeholder:e(`settings.remoteInstances.page.field.sshCommandPlaceholder`),disabled:m,autoFocus:!0}),(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(J,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>It(!1),disabled:m,children:e(`settings.common.actions.cancel`)}),(0,$.jsx)(J,{type:`submit`,size:`xs`,className:`!font-normal`,disabled:m||!Lt.trim(),children:e(`settings.common.actions.create`)})]})]})]})}):null,i?(0,$.jsx)(Kd,{label:e(`settings.remoteInstances.page.import.sectionTitle`),children:p?(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:e(`settings.remoteInstances.page.import.loading`)}):d.length===0?(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:e(`settings.remoteInstances.page.import.noneFound`)}):(0,$.jsx)(`div`,{children:d.map(t=>(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-[var(--surface-subtle)] py-3 last:border-b-0`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`div`,{className:`typography-ui-label font-medium text-foreground truncate`,children:[t.host,t.pattern?` ${e(`settings.remoteInstances.page.import.patternSuffix`)}`:``]}),(0,$.jsx)(`div`,{className:`typography-meta text-muted-foreground truncate`,children:t.sshCommand})]}),(0,$.jsx)(J,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>void Bn(t.host,t.pattern),children:e(`settings.common.actions.import`)})]},`${t.source}:${t.host}`))})}):null,(0,$.jsx)(Sd,{}),(0,$.jsx)(Qt,{open:!!he,onOpenChange:e=>{e||Rn()},children:(0,$.jsxs)(Yt,{className:`sm:max-w-md`,children:[(0,$.jsxs)(qt,{children:[(0,$.jsx)(Xt,{children:e(`settings.remoteInstances.page.patternDialog.title`)}),(0,$.jsx)(Zt,{children:he?e(`settings.remoteInstances.page.patternDialog.descriptionWithHost`,{host:he}):e(`settings.remoteInstances.page.patternDialog.description`)})]}),(0,$.jsxs)(`form`,{className:`space-y-3`,onSubmit:e=>{e.preventDefault(),Hn()},children:[(0,$.jsx)(fn,{value:_e,onChange:e=>ve(e.target.value),placeholder:e(`settings.remoteInstances.page.patternDialog.destinationPlaceholder`),autoFocus:!0}),(0,$.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,$.jsx)(J,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal`,onClick:Rn,disabled:ye,children:e(`settings.common.actions.cancel`)}),(0,$.jsx)(J,{type:`submit`,size:`xs`,className:`!font-normal`,disabled:ye,children:e(`settings.remoteInstances.page.actions.create`)})]})]})]})})]}),(0,$.jsx)(Fd,{open:se,instanceId:le,targetKind:de,relayHost:pe,onOpenChange:e=>{ce(e),e||(ue(null),fe(`ssh`),me(null))}})]});let rr=O.remoteOpenchamber.mode===`managed`,ir=O.nickname?.trim()||O.sshParsed?.destination||O.id;return(0,$.jsx)(Qt,{open:!!O,onOpenChange:e=>{e||E(null)},children:(0,$.jsxs)(Yt,{className:`oc-settings-workspace oc-settings-workspace-desktop oc-settings-section-stack sm:max-w-4xl max-h-[90vh] overflow-auto`,children:[(0,$.jsxs)(qt,{className:`gap-1 pr-8`,children:[(0,$.jsx)(Xt,{className:`truncate`,children:ir}),(0,$.jsxs)(Zt,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`h-2.5 w-2.5 rounded-full ${Hd(Dn)}`}),(0,$.jsx)(`span`,{children:e(zd(Dn))}),En?.localUrl?(0,$.jsx)(`span`,{className:`font-mono text-foreground/80`,children:En.localUrl}):null,Nn?(0,$.jsx)(`span`,{children:e(`settings.remoteInstances.page.status.reconnectStale`)}):null]})]}),Dn===`error`?(0,$.jsx)(_r,{errorCode:En?.errorCode,detail:En?.detail}):null,(0,$.jsxs)(vi,{label:e(`settings.remoteInstances.page.section.actions`),children:[(0,$.jsxs)(`div`,{className:`oc-settings-group-row flex flex-wrap items-center gap-2`,children:[(0,$.jsxs)(J,{type:`button`,variant:jn?`outline`:`default`,size:`xs`,className:`!font-normal`,onClick:Qn,disabled:Ce||Te,children:[jn?(0,$.jsx)(X,{name:`stop`,className:`h-3.5 w-3.5`}):(0,$.jsx)(X,{name:`plug-2`,className:`h-3.5 w-3.5`}),nr]}),(0,$.jsxs)(J,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal`,onClick:$n,disabled:!tr,children:[(0,$.jsx)(X,{name:`refresh`,className:`h-3.5 w-3.5 ${An||kn&&!Nn?`animate-spin`:``}`}),er]}),(0,$.jsxs)(J,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>{Kn()},children:[(0,$.jsx)(X,{name:`terminal-window`,className:`h-3.5 w-3.5`}),e(`settings.remoteInstances.page.actions.logs`)]}),(0,$.jsxs)(J,{type:`button`,variant:`destructive`,size:`xs`,className:`!font-normal`,onClick:()=>{window.confirm(e(`settings.remoteInstances.page.confirm.removeInstance`))&&x(O.id).then(()=>{E(null),Y.success(e(`settings.remoteInstances.page.toast.instanceRemoved`))}).catch(t=>{Y.error(e(`settings.remoteInstances.page.toast.removeInstanceFailed`),{description:t instanceof Error?t.message:String(t)})})},children:[(0,$.jsx)(X,{name:`delete-bin`,className:`h-3.5 w-3.5`}),e(`settings.remoteInstances.sidebar.actions.remove`)]})]}),En?.localUrl?(0,$.jsx)(Nr,{label:e(`settings.remoteInstances.page.status.currentLocalUrl`),children:(0,$.jsx)(`span`,{className:`font-mono text-foreground/90`,children:En.localUrl})}):null]}),(0,$.jsxs)(vi,{label:e(`settings.remoteInstances.page.section.instance`),children:[(0,$.jsx)(Nr,{label:e(`settings.remoteInstances.page.field.sshCommand`),className:`oc-settings-ssh-command-row`,children:(0,$.jsx)(fn,{value:O.sshCommand,onChange:e=>Z(t=>({...t,sshCommand:e.target.value})),placeholder:e(`settings.remoteInstances.page.field.sshCommandPlaceholder`)})}),(0,$.jsx)(Nr,{label:e(`settings.remoteInstances.page.field.nickname`),children:(0,$.jsx)(fn,{value:O.nickname||``,onChange:e=>Z(t=>({...t,nickname:e.target.value})),placeholder:e(`settings.remoteInstances.page.field.nicknamePlaceholder`)})}),(0,$.jsx)(Nr,{label:e(`settings.remoteInstances.page.field.connectionTimeoutSeconds`),children:(0,$.jsx)(Fr,{min:5,max:240,step:1,className:`tabular-nums`,value:O.connectionTimeoutSec,onValueChange:e=>{Z(t=>({...t,connectionTimeoutSec:Number.isFinite(e)?e:t.connectionTimeoutSec}))}})})]}),(0,$.jsxs)(vi,{label:e(`settings.remoteInstances.page.section.remoteServer`),children:[(0,$.jsx)(Nr,{label:e(`settings.remoteInstances.page.field.mode`),children:(0,$.jsxs)(ln,{value:O.remoteOpenchamber.mode,onValueChange:e=>Z(t=>({...t,remoteOpenchamber:{...t.remoteOpenchamber,mode:e===`external`?`external`:`managed`}})),children:[(0,$.jsx)(rn,{children:(0,$.jsx)(dn,{placeholder:e(`settings.remoteInstances.page.field.modePlaceholder`)})}),(0,$.jsxs)(an,{children:[(0,$.jsx)(tn,{value:`managed`,children:e(`settings.remoteInstances.page.field.modeManaged`)}),(0,$.jsx)(tn,{value:`external`,children:e(`settings.remoteInstances.page.field.modeExternal`)})]})]})}),(0,$.jsx)(Nr,{label:e(`settings.remoteInstances.page.field.preferredRemotePort`),children:(0,$.jsx)(Fr,{min:1,max:65535,step:1,className:`tabular-nums`,value:O.remoteOpenchamber.preferredPort,onValueChange:e=>{Z(t=>({...t,remoteOpenchamber:{...t.remoteOpenchamber,preferredPort:Number.isFinite(e)&&e>0?e:void 0}}))},onClear:()=>{Z(e=>({...e,remoteOpenchamber:{...e.remoteOpenchamber,preferredPort:void 0}}))},emptyLabel:e(`settings.remoteInstances.page.field.auto`)})}),rr?(0,$.jsx)(Nr,{label:e(`settings.remoteInstances.page.field.installMethod`),children:(0,$.jsxs)(ln,{value:O.remoteOpenchamber.installMethod,onValueChange:e=>Z(t=>({...t,remoteOpenchamber:{...t.remoteOpenchamber,installMethod:e===`npm`||e===`download_release`||e===`upload_bundle`?e:`bun`}})),children:[(0,$.jsx)(rn,{children:(0,$.jsx)(dn,{placeholder:e(`settings.remoteInstances.page.field.selectInstallMethodPlaceholder`)})}),(0,$.jsxs)(an,{children:[(0,$.jsx)(tn,{value:`bun`,children:`bun`}),(0,$.jsx)(tn,{value:`npm`,children:`npm`}),(0,$.jsx)(tn,{value:`download_release`,children:e(`settings.remoteInstances.page.field.installMethodDownloadRelease`)}),(0,$.jsx)(tn,{value:`upload_bundle`,children:e(`settings.remoteInstances.page.field.installMethodUploadBundle`)})]})]})}):null,rr?(0,$.jsx)(Qr,{checked:O.remoteOpenchamber.keepRunning,onChange:e=>Z(t=>({...t,remoteOpenchamber:{...t.remoteOpenchamber,keepRunning:e}})),label:e(`settings.remoteInstances.page.field.keepServerRunning`),ariaLabel:e(`settings.remoteInstances.page.field.keepServerRunning`)}):null]}),(0,$.jsxs)(vi,{label:e(`settings.remoteInstances.page.section.mainTunnel`),children:[(0,$.jsx)(Nr,{label:e(`settings.remoteInstances.page.field.bindHost`),children:(0,$.jsxs)(ln,{value:O.localForward.bindHost,onValueChange:t=>{t===`0.0.0.0`&&!window.confirm(e(`settings.remoteInstances.page.confirm.bindAllInterfaces`))||Z(e=>({...e,localForward:{...e.localForward,bindHost:t===`localhost`||t===`0.0.0.0`?t:`127.0.0.1`}}))},children:[(0,$.jsx)(rn,{children:(0,$.jsx)(dn,{placeholder:e(`settings.remoteInstances.page.field.selectBindHostPlaceholder`)})}),(0,$.jsxs)(an,{children:[(0,$.jsx)(tn,{value:`127.0.0.1`,children:`127.0.0.1`}),(0,$.jsx)(tn,{value:`localhost`,children:`localhost`}),(0,$.jsx)(tn,{value:`0.0.0.0`,children:`0.0.0.0`})]})]})}),(0,$.jsxs)(Nr,{label:e(`settings.remoteInstances.page.field.preferredLocalPort`),children:[(0,$.jsx)(Fr,{min:1,max:65535,step:1,className:`tabular-nums`,value:O.localForward.preferredLocalPort,onValueChange:e=>{Z(t=>({...t,localForward:{...t.localForward,preferredLocalPort:Number.isFinite(e)&&e>0?e:void 0}}))},onClear:()=>{Z(e=>({...e,localForward:{...e.localForward,preferredLocalPort:void 0}}))},emptyLabel:e(`settings.remoteInstances.page.field.auto`)}),(0,$.jsx)(J,{type:`button`,variant:`outline`,size:`icon`,"aria-label":e(`settings.remoteInstances.page.actions.pickRandomPort`),onClick:()=>Z(e=>({...e,localForward:{...e.localForward,preferredLocalPort:kd()}})),children:(0,$.jsx)(X,{name:`shuffle`,className:`size-4`})})]})]}),(0,$.jsxs)(vi,{label:e(`settings.remoteInstances.page.section.authentication`),children:[(0,$.jsx)(Nr,{label:e(`settings.remoteInstances.page.field.sshPasswordOptional`),children:(0,$.jsx)(fn,{type:`password`,value:O.auth.sshPassword?.value||``,onChange:e=>Z(t=>({...t,auth:{...t.auth,sshPassword:{enabled:e.target.value.trim().length>0,value:e.target.value,store:t.auth.sshPassword?.store||`never`}}})),placeholder:e(`settings.remoteInstances.page.field.sshPasswordPlaceholder`)})}),(0,$.jsx)(Nr,{label:e(`settings.remoteInstances.page.field.uiPasswordOptional`),children:(0,$.jsx)(fn,{type:`password`,value:O.auth.openchamberPassword?.value||``,onChange:e=>Z(t=>({...t,auth:{...t.auth,openchamberPassword:{enabled:e.target.value.trim().length>0,value:e.target.value,store:t.auth.openchamberPassword?.store||`never`}}})),placeholder:e(`settings.remoteInstances.page.field.uiPasswordPlaceholder`)})})]}),rr?(0,$.jsx)(vi,{label:e(`settings.remoteInstances.page.sync.runs.title`),children:A.length===0?(0,$.jsx)(`div`,{className:`oc-settings-group-row typography-meta text-muted-foreground`,children:e(`settings.remoteInstances.page.sync.runs.empty`)}):A.map(t=>(0,$.jsxs)(`div`,{className:`oc-settings-group-row flex items-center gap-2 typography-meta`,children:[(0,$.jsx)(`span`,{className:q(`shrink-0`,t.result===`success`?`text-[var(--status-success)]`:`text-[var(--status-error)]`),children:t.result===`success`?e(`settings.remoteInstances.page.sync.runs.result.success`):e(`settings.remoteInstances.page.sync.runs.result.failure`)}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1 truncate text-muted-foreground`,children:[t.direction===`pull`?e(`settings.remoteInstances.page.sync.direction.pull`):e(`settings.remoteInstances.page.sync.direction.push`),t.endedAt?` · ${t.endedAt}`:``]})]},t.syncRunId))}):null,(0,$.jsxs)(vi,{label:e(`settings.remoteInstances.page.section.portForwards`),children:[O.portForwards.length===0?(0,$.jsx)(`div`,{className:`oc-settings-group-row typography-meta text-muted-foreground`,children:e(`settings.remoteInstances.page.empty.noExtraForwards`)}):null,O.portForwards.map((t,n)=>{let r=e=>{Z(t=>({...t,portForwards:t.portForwards.map((t,r)=>r===n?e(t):t)}))},i=t.type===`remote`?e(`settings.remoteInstances.page.field.localTarget`):e(`settings.remoteInstances.page.field.localListen`),a=t.type===`remote`?e(`settings.remoteInstances.page.field.remoteListen`):e(`settings.remoteInstances.page.field.remoteTarget`),o=Jd(t.localHost||`localhost`,t.localPort),s=Jd(t.remoteHost||`localhost`,t.remotePort),c=t.type===`local`&&typeof t.localPort==`number`&&t.localPort>0,l=c?`http://${Yd(t.localHost)}:${t.localPort}`:``,u=!!xe[t.id],d=t.type===`local`?e(`settings.remoteInstances.page.forwardType.local`):t.type===`remote`?e(`settings.remoteInstances.page.forwardType.remote`):e(`settings.remoteInstances.page.forwardType.dynamic`);return(0,$.jsxs)(Mi,{open:u,onOpenChange:e=>{Se(n=>({...n,[t.id]:e}))},className:`oc-settings-group-row`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`div`,{className:`min-w-0 flex items-center gap-2`,children:(0,$.jsxs)(ji,{className:`flex items-center gap-2 group`,children:[(0,$.jsx)(X,{name:`arrow-down-s`,className:`h-4 w-4 text-muted-foreground transition-transform ${u?`rotate-180`:``}`}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground truncate`,children:Ud(t)}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground/70 shrink-0`,children:d})]})}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(sn,{checked:t.enabled,onChange:e=>r(t=>({...t,enabled:e})),ariaLabel:e(`settings.remoteInstances.page.actions.enableForwardAria`)}),(0,$.jsx)(J,{type:`button`,variant:`destructive`,size:`icon`,"aria-label":e(`settings.remoteInstances.sidebar.actions.remove`),onClick:()=>Z(e=>({...e,portForwards:e.portForwards.filter(e=>e.id!==t.id)})),children:(0,$.jsx)(X,{name:`delete-bin`,className:`size-4`})})]})]}),(0,$.jsx)(Ai,{className:`pt-2`,children:(0,$.jsxs)(`div`,{className:`flex flex-col`,children:[(0,$.jsx)(Nr,{label:e(`settings.remoteInstances.page.field.forwardType`),description:e(qd(t.type)),children:(0,$.jsxs)(ln,{value:t.type,onValueChange:e=>r(t=>({...t,type:e===`dynamic`||e===`remote`?e:`local`})),children:[(0,$.jsx)(rn,{children:(0,$.jsx)(dn,{placeholder:e(`settings.remoteInstances.page.field.typePlaceholder`)})}),(0,$.jsxs)(an,{children:[(0,$.jsx)(tn,{value:`local`,children:e(`settings.remoteInstances.page.forwardType.local`)}),(0,$.jsx)(tn,{value:`remote`,children:e(`settings.remoteInstances.page.forwardType.remote`)}),(0,$.jsx)(tn,{value:`dynamic`,children:e(`settings.remoteInstances.page.forwardType.dynamic`)})]})]})}),(0,$.jsx)(Nr,{label:i,className:`oc-settings-ssh-endpoint-row`,children:(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,$.jsx)(fn,{className:`min-w-0`,value:t.localHost||`127.0.0.1`,onChange:e=>r(t=>({...t,localHost:e.target.value})),placeholder:e(`settings.remoteInstances.page.field.localHostPlaceholder`)}),(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:`:`}),(0,$.jsx)(Fr,{min:1,max:65535,step:1,className:`tabular-nums`,value:t.localPort,onValueChange:e=>{r(t=>({...t,localPort:Number.isFinite(e)&&e>0?e:void 0}))},onClear:()=>{r(e=>({...e,localPort:void 0}))},emptyLabel:e(`settings.remoteInstances.page.field.auto`)})]})}),t.type===`dynamic`?null:(0,$.jsx)(Nr,{label:a,className:`oc-settings-ssh-endpoint-row`,children:(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,$.jsx)(fn,{className:`min-w-0`,value:t.remoteHost||``,onChange:e=>r(t=>({...t,remoteHost:e.target.value})),placeholder:e(`settings.remoteInstances.page.field.remoteHostPlaceholder`)}),(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:`:`}),(0,$.jsx)(Fr,{min:1,max:65535,step:1,className:`tabular-nums`,value:t.remotePort,onValueChange:e=>{r(t=>({...t,remotePort:Number.isFinite(e)&&e>0?e:void 0}))},onClear:()=>{r(e=>({...e,remotePort:void 0}))},emptyLabel:e(`settings.remoteInstances.page.field.auto`)})]})}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 pt-2`,children:[(0,$.jsx)(`div`,{className:`flex flex-wrap items-center gap-1 typography-micro text-muted-foreground/80`,children:t.type===`dynamic`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(X,{name:`computer`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{className:`font-mono text-foreground`,children:o}),(0,$.jsx)(`span`,{children:e(`settings.remoteInstances.page.preview.localSocks5`)})]}):t.type===`remote`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(X,{name:`server`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{className:`font-mono text-foreground`,children:s}),(0,$.jsx)(`span`,{children:e(`settings.remoteInstances.page.preview.remote`)}),(0,$.jsx)(X,{name:`arrow-right`,className:`h-3.5 w-3.5`}),(0,$.jsx)(X,{name:`computer`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{className:`font-mono text-foreground`,children:o}),(0,$.jsx)(`span`,{children:e(`settings.remoteInstances.page.preview.local`)})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(X,{name:`computer`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{className:`font-mono text-foreground`,children:o}),(0,$.jsx)(`span`,{children:e(`settings.remoteInstances.page.preview.local`)}),(0,$.jsx)(X,{name:`arrow-right`,className:`h-3.5 w-3.5`}),(0,$.jsx)(X,{name:`server`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{className:`font-mono text-foreground`,children:s}),(0,$.jsx)(`span`,{children:e(`settings.remoteInstances.page.preview.remote`)})]})}),c?(0,$.jsxs)(J,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>{kr(l).then(t=>{t||Y.error(e(`settings.remoteInstances.page.toast.openLocalEndpointFailed`))})},children:[(0,$.jsx)(X,{name:`external-link`,className:`h-3.5 w-3.5`}),e(`settings.remoteInstances.page.actions.openLocal`)]}):null]})]})})]},t.id)}),(0,$.jsx)(`div`,{className:`oc-settings-group-row`,children:(0,$.jsxs)(J,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>{let e=Wd();Z(t=>({...t,portForwards:[...t.portForwards,e]})),Se(t=>({...t,[e.id]:!0}))},children:[(0,$.jsx)(X,{name:`add`,className:`h-3.5 w-3.5`}),e(`settings.remoteInstances.page.actions.addForward`)]})})]}),(0,$.jsxs)(Jt,{className:`flex-wrap`,children:[h?(0,$.jsx)(`div`,{className:`sm:mr-auto typography-meta text-[var(--status-error)]`,children:h}):null,En?.localUrl?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(J,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>{Xn()},children:[(0,$.jsx)(X,{name:`external-link`,className:`h-3.5 w-3.5`}),e(`settings.remoteInstances.page.actions.open`)]}),(0,$.jsxs)(J,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>{je(En.localUrl||``).then(t=>{t.ok&&Y.success(e(`settings.remoteInstances.page.toast.localUrlCopied`))})},children:[(0,$.jsx)(X,{name:`file-copy`,className:`h-3.5 w-3.5`}),e(`settings.remoteInstances.page.actions.copyLocalUrl`)]})]}):null,(0,$.jsx)(J,{type:`button`,size:`xs`,className:`!font-normal`,onClick:()=>void In(),disabled:!Fn||m,children:e(`settings.common.actions.saveChanges`)})]}),(0,$.jsx)(Fd,{open:se,instanceId:le,targetKind:de,relayHost:pe,onOpenChange:e=>{ce(e),e||(ue(null),fe(`ssh`),me(null))}}),(0,$.jsx)(Qt,{open:M,onOpenChange:N,children:(0,$.jsxs)(Yt,{className:`sm:max-w-2xl`,children:[(0,$.jsxs)(qt,{children:[(0,$.jsx)(Xt,{children:e(`settings.remoteInstances.page.logsDialog.title`)}),(0,$.jsx)(Zt,{children:O?.nickname?.trim()||O?.sshParsed?.destination||O?.id||e(`settings.remoteInstances.page.logsDialog.selectedInstanceFallback`)})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,$.jsxs)(J,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal`,onClick:Jn,disabled:F||!qn.trim(),children:[(0,$.jsx)(X,{name:`file-copy`,className:`h-3.5 w-3.5`}),e(`settings.common.actions.copyAll`)]}),(0,$.jsxs)(J,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>void Yn(),disabled:F,children:[(0,$.jsx)(X,{name:`delete-bin`,className:`h-3.5 w-3.5`}),e(`settings.common.actions.clear`)]})]}),F?(0,$.jsx)(`div`,{className:`typography-meta text-muted-foreground`,children:e(`settings.remoteInstances.page.logsDialog.loading`)}):L?(0,$.jsx)(`div`,{className:`typography-meta text-[var(--status-error)]`,children:L}):(0,$.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:z.length>0?z.join(`
|
|
24
|
+
`):e(`settings.remoteInstances.page.logsDialog.empty`)})]})}),(0,$.jsx)(Qt,{open:!!he,onOpenChange:e=>{e||Rn()},children:(0,$.jsxs)(Yt,{className:`sm:max-w-md`,children:[(0,$.jsxs)(qt,{children:[(0,$.jsx)(Xt,{children:e(`settings.remoteInstances.page.patternDialog.title`)}),(0,$.jsx)(Zt,{children:he?e(`settings.remoteInstances.page.patternDialog.descriptionWithHost`,{host:he}):e(`settings.remoteInstances.page.patternDialog.description`)})]}),(0,$.jsxs)(`form`,{className:`space-y-3`,onSubmit:e=>{e.preventDefault(),Hn()},children:[(0,$.jsx)(fn,{value:_e,onChange:e=>ve(e.target.value),placeholder:e(`settings.remoteInstances.page.patternDialog.destinationPlaceholder`),autoFocus:!0}),(0,$.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,$.jsx)(J,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal`,onClick:Rn,disabled:ye,children:e(`settings.common.actions.cancel`)}),(0,$.jsx)(J,{type:`submit`,size:`xs`,className:`!font-normal`,disabled:ye,children:e(`settings.common.actions.create`)})]})]})]})})]})})},rf=`__add_provider__`,af=()=>{let e=pe.getDirectory();return typeof e==`string`&&e.trim().length>0?e.trim():null},of=({onItemSelect:e})=>{let{t}=Me(),n=Mt(e=>e.providers),r=Mt(e=>e.selectedProviderId),i=Mt(e=>e.setSelectedProvider),a=Ct(e=>e.activeProjectId),[o,s]=Q.useState({}),c=Q.useMemo(()=>af(),[a]);Q.useEffect(()=>{if(n.length===0){s({});return}let e=!1;return(async()=>{let t=n.map(async t=>{try{let n=c?`?directory=${encodeURIComponent(c)}`:``,r=await l(`/api/provider/${encodeURIComponent(t.id)}/source${n}`,{method:`GET`,headers:{Accept:`application/json`}});if(!r.ok)return;let i=await r.json().catch(()=>null),a=i?.sources??i?.data?.sources;if(!a||e)return;s(e=>({...e,[t.id]:a}))}catch{}});await Promise.all(t)})(),()=>{e=!0}},[c,n]);let u=Q.useMemo(()=>n.filter(e=>!!o[e.id]?.project?.exists),[n,o]),d=Q.useMemo(()=>n.filter(e=>!o[e.id]?.project?.exists),[n,o]),f=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,$.jsx)(`span`,{children:t(`settings.providers.sidebar.section.userProviders`)}),(0,$.jsx)(J,{size:`icon`,variant:`ghost`,onClick:()=>{i(rf),e?.()},"aria-label":t(`settings.providers.sidebar.actions.connectProviderAria`),title:t(`settings.providers.sidebar.actions.connectProviderTitle`),children:(0,$.jsx)(X,{name:`add`,className:`h-4 w-4`})})]});return(0,$.jsxs)(`div`,{className:`oc-settings-page-content h-full overflow-y-auto bg-background p-3`,children:[(0,$.jsx)(ja,{}),(0,$.jsx)($.Fragment,{children:n.length===0?(0,$.jsx)(vi,{label:f,children:(0,$.jsxs)(`div`,{className:`oc-settings-group-row py-12 text-center text-muted-foreground`,children:[(0,$.jsx)(X,{name:`stack`,className:`mx-auto mb-3 h-10 w-10 opacity-50`}),(0,$.jsx)(`p`,{className:`typography-ui-label font-medium`,children:t(`settings.providers.sidebar.empty.title`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 opacity-75`,children:t(`settings.providers.sidebar.empty.description`)})]})}):(0,$.jsxs)($.Fragment,{children:[d.length>0?(0,$.jsx)(vi,{label:f,children:d.map(t=>(0,$.jsx)(sf,{provider:t,selectedProviderId:r,onSelect:()=>{i(t.id),e?.()}},t.id))}):(0,$.jsx)(vi,{label:f,cardClassName:`hidden`,children:(0,$.jsx)(`span`,{})}),u.length>0&&(0,$.jsx)(vi,{label:t(`settings.providers.sidebar.section.projectProviders`),children:u.map(t=>(0,$.jsx)(sf,{provider:t,selectedProviderId:r,onSelect:()=>{i(t.id),e?.()}},t.id))})]})})]})},sf=e=>{let t=(0,Ii.c)(17),{provider:n,selectedProviderId:r,onSelect:i}=e,a=Array.isArray(n.models)?n.models.length:0,o=n.id===r,s=n.id,c=o?`bg-interactive-selection`:`hover:bg-interactive-hover`,l;t[0]===c?l=t[1]:(l=q(`oc-settings-group-row group relative flex items-center transition-colors duration-150 !min-h-0 py-2`,c),t[0]=c,t[1]=l);let u;t[2]===n.id?u=t[3]:(u=(0,$.jsx)(en,{providerId:n.id,className:`h-3.5 w-3.5 flex-shrink-0`}),t[2]=n.id,t[3]=u);let d=n.name||n.id,f;t[4]===d?f=t[5]:(f=(0,$.jsx)(`span`,{className:`typography-ui-label font-normal truncate flex-1 min-w-0 text-foreground`,children:d}),t[4]=d,t[5]=f);let p;t[6]===a?p=t[7]:(p=(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground/60 flex-shrink-0`,children:a}),t[6]=a,t[7]=p);let m;t[8]!==i||t[9]!==u||t[10]!==f||t[11]!==p?(m=(0,$.jsxs)(`button`,{type:`button`,onClick:i,className:`flex min-w-0 flex-1 items-center gap-1.5 rounded-sm text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,tabIndex:0,children:[u,f,p]}),t[8]=i,t[9]=u,t[10]=f,t[11]=p,t[12]=m):m=t[12];let h;return t[13]!==n.id||t[14]!==l||t[15]!==m?(h=(0,$.jsx)(`div`,{className:l,children:m},s),t[13]=n.id,t[14]=l,t[15]=m,t[16]=h):h=t[16],h},cf=(e,t)=>e.flatMap((e,n)=>t(e)?[{method:e,methodIndex:n}]:[]),lf=(e=pe.getDirectory())=>Te({queryKey:[i(),o(),`provider-connections`,e??null],queryFn:async({signal:t})=>{let n=pe.getSdkClient(),r=e?{directory:e}:void 0,[i,a]=await Promise.all([n.provider.list({location:r},{signal:t}),n.integration.list({location:r},{signal:t})]);return{providers:i.data,integrations:a.data}}});function uf(e){let t=pe.getSdkClient(),n=o(),r=pe.getDirectory(),i=r?{directory:r}:void 0,a=new AbortController,s,c,l,u=!1,d=!1,f=!1,p=()=>!a.signal.aborted&&n===o()&&r===pe.getDirectory(),m=()=>{clearTimeout(c),clearTimeout(l)},h=()=>{s&&!d&&!f&&n===o()&&(f=!0,t.integration.oauth.cancel({integrationID:e.integrationID,attemptID:s.attemptID,location:i}).catch(()=>void 0))},g=()=>{a.abort(),m(),h()},_=t=>{p()&&(g(),e.onError(t))},v=async()=>{p()&&(d=!0,m(),await e.onSuccess())},y=async()=>{if(!(!p()||!s))try{let n=await t.integration.oauth.status({integrationID:e.integrationID,attemptID:s.attemptID,location:i},{signal:a.signal});if(!p())return;if(n.data.status===`complete`){await v();return}if(n.data.status!==`pending`){_(`complete`);return}c=setTimeout(()=>{y()},1500)}catch{_(`complete`)}};return{cancel:g,isCurrent:p,async start(n){l=setTimeout(()=>_(`start`),3e4);try{if(s=(await t.integration.oauth.connect({integrationID:e.integrationID,methodID:n,location:i},{signal:a.signal})).data,!p()){h();return}if(clearTimeout(l),!s.attemptID||![`auto`,`code`].includes(s.mode)){_(`start`);return}let r=Math.min(6e5,(s.time?.expires??Date.now()+6e5)-Date.now());if(r<=0){_(`complete`);return}l=setTimeout(()=>_(`complete`),r),e.onAttempt(s),s.mode===`auto`&&y()}catch{_(`start`)}},async complete(n){if(!(!p()||!s||s.mode!==`code`||u||!n.trim())){u=!0;try{await t.integration.oauth.complete({integrationID:e.integrationID,attemptID:s.attemptID,code:n.trim(),location:i},{signal:a.signal}),await v()}catch{_(`complete`)}}}}}var df=`opencode`;function ff(e){return e===`opencode-go`?df:e}function pf(e,t){let n=ff(e);return t?.find(e=>e.id===n)}function mf(e){return(e?.connections??[]).some(e=>e.type===`credential`&&e.method===`oauth`)}function hf(e){return(e?.methods??[]).flatMap(e=>e.type===`oauth`&&typeof e.id==`string`&&e.id?[{id:e.id,label:e.label??e.name}]:[])}function gf(e,t){return t[ff(e)]??t[e]??[]}function _f(e,t){let n=ff(e);return n===e?t[e]||e:t[n]||n}var vf=({providerId:e,providerName:t})=>{let{t:n}=Me(),[r,i]=Q.useState(null),[a,o]=Q.useState({}),[s,c]=Q.useState(!1),[u,d]=Q.useState(null),[f,p]=Q.useState(``),[m,h]=Q.useState(!1),g=Q.useRef(null),_=Ee({...lf(),enabled:e===`opencode-go`}),v=`/api/quota/credentials/${e}`,y=e===`opencode-go`?pf(e,_.data?.integrations):void 0,b=mf(y),x=hf(y);Q.useEffect(()=>{l(v).then(async e=>{if(!e.ok)throw Error();let t=await e.json();i(t),o(t.workspaceId?{workspaceId:t.workspaceId}:{})}).catch(()=>i({configured:!1}))},[v]);let S=Ae(()=>{g.current?.cancel(),g.current=null,d(null),p(``),h(!1)});Q.useEffect(()=>()=>{g.current?.cancel(),g.current=null},[]);let C=async(e,r,a)=>{c(!0);try{let s=await l(e,{method:r,headers:a?{"Content-Type":`application/json`}:void 0,body:a?JSON.stringify(a):void 0}),c=await s.json().catch(()=>null);if(!s.ok)throw Error(c?.error);c?.configured!==void 0&&i(c),o(e=>e.workspaceId?{workspaceId:e.workspaceId}:{}),Y.success(n(`settings.providers.page.quotaCredentials.saved`,{provider:t}))}catch(e){Y.error(e instanceof Error&&e.message?e.message:n(`settings.providers.page.openCodeGo.saveFailed`))}finally{c(!1)}},w=Ae(async e=>{let t=ff(`opencode-go`);if(!e||t===`opencode-go`){Y.error(n(`settings.providers.page.toast.oauthStartFailed`));return}S(),h(!0);let r=uf({integrationID:t,onAttempt:({mode:t,url:r,instructions:i})=>{d({methodID:e,mode:t,url:r,instructions:i,userCode:/[A-Z0-9]{4}-[A-Z0-9]{4,5}/.exec(i)?.[0]}),t===`code`&&h(!1),r&&kr(r),Y.message(n(`settings.providers.page.toast.completeOAuthInBrowser`))},onSuccess:async()=>{d(null),p(``),h(!1);try{if(await tt({scopes:[`providers`],mode:`active`}),!r.isCurrent()||g.current!==r)return;await _.refetch({throwOnError:!0})}catch{r.isCurrent()&&g.current===r&&Y.error(n(`settings.providers.page.toast.authMethodsLoadFailed`))}!r.isCurrent()||g.current!==r||Y.success(n(`settings.providers.page.toast.oauthCompleted`))},onError:e=>{h(!1),d(null),p(``),Y.error(n(e===`start`?`settings.providers.page.toast.oauthStartFailed`:`settings.providers.page.toast.oauthCompleteFailed`))}});g.current=r,await r.start(e)}),T=Ae(async()=>{!f.trim()||u?.mode!==`code`||(h(!0),await g.current?.complete(f))}),E=Ae(async(e,t,r)=>{(await je(e)).ok?Y.success(n(t)):Y.error(n(r))}),D=(e,t,n)=>(0,$.jsxs)(`label`,{className:`oc-settings-group-row flex flex-col gap-1 typography-ui-label text-foreground`,children:[t,(0,$.jsx)(fn,{className:`font-mono text-xs`,type:e===`workspaceId`?`text`:`password`,autoComplete:`off`,value:a[e]??``,onChange:t=>o(n=>({...n,[e]:t.target.value})),placeholder:r?.secretMasked??n})]});return(0,$.jsx)(`div`,{"data-settings-item":`providers.${e}-credentials`,children:(0,$.jsxs)(vi,{label:t,className:`oc-settings-detail-group`,children:[e===`opencode-go`&&(0,$.jsx)(`div`,{className:`oc-settings-group-row space-y-3`,children:_.isPending?(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:n(`settings.providers.page.auth.loadingMethods`)}):b?(0,$.jsxs)(`div`,{className:`flex items-start gap-1.5 py-1.5`,role:`status`,children:[(0,$.jsx)(X,{name:`check`,className:`mt-0.5 h-4 w-4 shrink-0 text-[var(--status-success)]`}),(0,$.jsx)(`p`,{className:`min-w-0 typography-ui-label text-foreground`,children:n(`settings.providers.page.openCodeGo.consoleConnected`)})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:n(`settings.providers.page.openCodeGo.consoleHint`)}),(x.length>0?x:[{id:``,label:void 0}]).map(e=>{let t=u?.methodID===e.id;return(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsx)(`p`,{className:`min-w-0 typography-ui-label text-foreground`,children:e.label||n(`settings.providers.page.openCodeGo.consoleSignIn`)}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,$.jsx)(J,{size:`xs`,className:`!font-normal w-full sm:w-auto`,"aria-busy":m,disabled:m||!e.id,onClick:()=>void w(e.id),children:m&&u?.mode===`auto`?n(`settings.providers.page.state.loading`):n(`settings.providers.page.openCodeGo.consoleSignIn`)}),t&&(0,$.jsx)(J,{variant:`ghost`,size:`xs`,className:`!font-normal`,onClick:S,children:n(`settings.common.actions.cancel`)})]})]}),t&&u?.instructions&&(0,$.jsx)(`p`,{className:`typography-meta text-[var(--primary-base)] bg-[var(--primary-base)]/10 px-2 py-1.5 rounded`,children:u.instructions}),t&&u?.userCode&&(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center`,children:[(0,$.jsx)(fn,{value:u.userCode,readOnly:!0,className:`min-w-0 flex-1 font-mono text-center tracking-widest`}),(0,$.jsx)(J,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>void E(u.userCode??``,`settings.providers.page.toast.deviceCodeCopied`,`settings.providers.page.toast.deviceCodeCopyFailed`),children:n(`settings.providers.page.actions.copyCode`)})]}),t&&u?.url&&(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center`,children:[(0,$.jsx)(fn,{value:u.url,readOnly:!0,className:`min-w-0 flex-1 text-xs text-muted-foreground`}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-1`,children:[(0,$.jsx)(J,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>kr(u.url??``),children:n(`settings.providers.page.actions.open`)}),(0,$.jsx)(J,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>void E(u.url??``,`settings.providers.page.toast.oauthLinkCopied`,`settings.providers.page.toast.oauthLinkCopyFailed`),children:n(`settings.providers.page.actions.copy`)})]})]}),t&&u?.mode===`code`&&(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center`,children:[(0,$.jsx)(fn,{value:f,onChange:e=>p(e.target.value),placeholder:n(`settings.providers.page.auth.pasteAuthorizationCodePlaceholder`),className:`min-w-0 flex-1 font-mono text-xs`,"aria-label":n(`settings.providers.page.auth.pasteAuthorizationCodePlaceholder`)}),(0,$.jsx)(J,{size:`xs`,className:`!font-normal`,onClick:()=>void T(),disabled:m||!f.trim(),children:n(m?`settings.providers.page.actions.saving`:`settings.providers.page.actions.complete`)})]})]},e.id||`console`)})]})}),e===`opencode-go`&&D(`workspaceId`,n(`settings.providers.page.openCodeGo.workspaceId`),`wrk_...`),e===`opencode-go`&&D(`authCookie`,n(`settings.providers.page.openCodeGo.authCookie`),`auth=...`),e===`ollama-cloud`&&D(`cookie`,n(`settings.providers.page.openCodeGo.authCookie`),`session=...`),e===`cursor`&&D(`accessToken`,n(`settings.providers.page.auth.apiKeyLabel`),n(`settings.providers.page.auth.apiKeyPlaceholder`)),e===`cursor`&&D(`refreshToken`,n(`settings.providers.page.auth.apiKeyLabel`),n(`settings.providers.page.auth.apiKeyPlaceholder`)),(0,$.jsxs)(`div`,{className:`oc-settings-group-row flex flex-wrap gap-2`,children:[(0,$.jsx)(J,{size:`xs`,disabled:s,onClick:()=>C(v,`PUT`,a),children:r?.configured?n(`settings.providers.page.openCodeGo.replace`):n(`settings.providers.page.openCodeGo.save`)}),r?.configured&&(0,$.jsx)(J,{variant:`outline`,size:`xs`,disabled:s,onClick:()=>C(`${v}/validate`,`POST`),children:n(`settings.providers.page.openCodeGo.validate`)}),e===`cursor`&&(0,$.jsx)(J,{variant:`outline`,size:`xs`,disabled:s,onClick:()=>C(`${v}/import`,`POST`),children:n(`settings.providers.page.actions.connect`)}),r?.configured&&(0,$.jsx)(J,{variant:`destructive`,size:`xs`,disabled:s,onClick:()=>C(v,`DELETE`),children:n(`settings.providers.page.openCodeGo.delete`)})]})]})})},yf=e=>{let t=(0,Ii.c)(12),{itemId:n,label:r,description:i,action:a,children:o}=e,s;t[0]!==a||t[1]!==r?(s=a?(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-2`,children:[(0,$.jsx)(`div`,{className:`min-w-0`,children:r}),(0,$.jsx)(`div`,{className:`shrink-0`,children:a})]}):r,t[0]=a,t[1]=r,t[2]=s):s=t[2];let c;t[3]===o?c=t[4]:(c=(0,$.jsx)(`div`,{className:`oc-settings-group-row`,children:o}),t[3]=o,t[4]=c);let l;t[5]!==i||t[6]!==s||t[7]!==c?(l=(0,$.jsx)(vi,{className:`oc-settings-detail-group`,label:s,description:i,children:c}),t[5]=i,t[6]=s,t[7]=c,t[8]=l):l=t[8];let u;return t[9]!==n||t[10]!==l?(u=(0,$.jsx)(`div`,{"data-settings-item":n,children:l}),t[9]=n,t[10]=l,t[11]=u):u=t[11],u},bf=e=>new Intl.NumberFormat(Pe(),{notation:`compact`,compactDisplay:`short`,maximumFractionDigits:1,minimumFractionDigits:0}).format(e),xf=e=>{if(typeof e!=`number`||Number.isNaN(e))return null;if(e===0)return`0`;let t=bf(e);return t.endsWith(`.0`)?t.slice(0,-2):t},Sf=`__add_provider__`,Cf=e=>{let t=typeof e.type==`string`?e.type:``,n=`${t} ${`${e.name??``} ${e.label??``}`.toLowerCase()}`.toLowerCase();return n.includes(`oauth`)?`oauth`:n.includes(`api`)?`api`:t.toLowerCase()},wf=(e,t,n)=>{let r=t.find(t=>t.id===e);return typeof r?.integrationID==`string`&&r.integrationID?r.integrationID:(n.some(t=>t.id===e),e)},Tf=(e,t)=>{let n={},r={},i=new Map(t.filter(e=>typeof e.id==`string`&&e.id.length>0).map(e=>[e.id,e])),a=(e,t)=>{r[e]=t.id??e,n[e]=(t.methods??[]).map(e=>({type:e.type,id:e.id,name:e.label??e.name,label:e.label??e.name}))};for(let n of e){if(typeof n.id!=`string`||!n.id)continue;let r=wf(n.id,e,t),o=i.get(r);o&&a(n.id,o)}for(let e of t)typeof e.id!=`string`||!e.id||n[e.id]||a(e.id,e);return{methodsByProvider:n,integrationIdByProvider:r}},Ef=()=>{let e=(0,Ii.c)(2),t=`${Q.useSyncExternalStore(r,o,o)}:${fe(Of)}`,n;return e[0]===t?n=e[1]:(n=(0,$.jsx)(Df,{},t),e[0]=t,e[1]=n),n},Df=()=>{let{t:e}=Me(),t=Mt(e=>e.providers),n=Mt(e=>e.selectedProviderId),r=Mt(e=>e.setSelectedProvider),a=Mt(e=>e.getModelMetadata),s=K(e=>e.hiddenModels),c=K(e=>e.toggleHiddenModel),u=K(e=>e.hideAllModels),d=K(e=>e.showAllModels),f=Ee(lf()),{methodsByProvider:p,integrationIdByProvider:m}=Q.useMemo(()=>Tf(f.data?.providers??[],f.data?.integrations??[]),[f.data]),h=f.isPending;Q.useEffect(()=>{f.isError&&Y.error(e(`settings.providers.page.toast.authMethodsLoadFailed`))},[f.isError,e]);let[g,_]=Q.useState({}),[v,y]=Q.useState(null),[b,x]=Q.useState(``),[S,C]=Q.useState(null),[w,T]=Q.useState({}),[E,D]=Q.useState({}),O=f.isPending,k=f.isError?e(`settings.providers.page.state.unableToLoadProviderList`):null,[A,j]=Q.useState(``),[M,N]=Q.useState(``),[P,F]=Q.useState(!1),[I,L]=Q.useState({}),[R,z]=Q.useState(!1),B=n===Sf,V=Q.useRef(null);Q.useEffect(()=>{let e=new AbortController;return V.current=e,()=>e.abort()},[]);let H=Ae(()=>{let e=V.current;if(!e||e.signal.aborted)return null;let t=pe.getDirectory(),n=o();return{directory:t,location:t?{directory:t}:void 0,transportIdentity:i(),signal:e.signal,isCurrent:()=>V.current===e&&!e.signal.aborted&&o()===n&&pe.getDirectory()===t}}),U=Q.useRef(null),W=Ae(()=>{U.current?.cancel(),U.current=null,C(null),D({}),T({}),y(null)});Q.useEffect(()=>(W(),()=>{U.current?.cancel(),U.current=null}),[n,A,W]),Q.useEffect(()=>{!n&&t.length>0&&r(t[0].id)},[t,n,r]);let ee=Q.useMemo(()=>(f.data?.integrations??[]).filter(e=>!e.id.startsWith(`mcp_`)&&e.connections.length===0).sort((e,t)=>{let n=(e.name||e.id).toLowerCase(),r=(t.name||t.id).toLowerCase();return n.localeCompare(r)}),[f.data]);Q.useEffect(()=>{n===Sf&&A&&!ee.some(e=>e.id===A)&&j(``)},[n,A,ee]),Q.useEffect(()=>{if(n===Sf){z(!0);return}z(!1)},[n,e]),Q.useEffect(()=>{if(!n||n===Sf)return;let t=!1;return(async()=>{try{let r=await l(`/api/provider/${encodeURIComponent(n)}/source`,{method:`GET`,headers:{Accept:`application/json`}}),i=await r.json().catch(()=>null);if(!r.ok)throw Error(i?.error||e(`settings.providers.page.toast.providerSourcesLoadFailed`));let a=i?.sources??i?.data?.sources;!t&&a&&L(e=>({...e,[n]:a}))}catch(e){t||console.error(`Failed to load provider sources:`,e)}})(),()=>{t=!0}},[n,e]);let G=t.find(e=>e.id===n),te=n?I[n]:void 0,ne=Ae(async t=>{let n=g[t]?.trim()??``;if(!n){Y.error(e(`settings.providers.page.toast.apiKeyRequired`));return}let i=H();if(!i)return;let a=`api:${t}`;y(a);try{let a=m[t]||t;if(await pe.getSdkClient().integration.connect.key({integrationID:a,key:n,location:i.location},{signal:i.signal}),!i.isCurrent()||(_(e=>({...e,[t]:``})),await tt({scopes:[`providers`],mode:`active`,queryDirectory:i.directory,transportIdentity:i.transportIdentity}),!i.isCurrent()))return;let o=await f.refetch({throwOnError:!0});if(!i.isCurrent())return;let s=o.data?.providers.find(e=>e.id===t||e.integrationID===a);s&&r(s.id),Y.success(e(`settings.providers.page.toast.apiKeySaved`))}catch{i.isCurrent()&&Y.error(e(`settings.providers.page.toast.apiKeySaveFailed`))}finally{i.isCurrent()&&y(null)}}),re=Ae(async(t,n)=>{W();let i=`oauth:${t}:${n}`;y(i);let a=gf(t,p)[n],o=typeof a?.id==`string`?a.id:``;if(!o){y(null),Y.error(e(`settings.providers.page.toast.oauthStartFailed`));return}let s=_f(t,m),c=m[t]||t,l=uf({integrationID:s,onAttempt:({attemptID:r,mode:i,url:a,instructions:c})=>{D({[`${t}:${n}`]:{url:a,instructions:c,mode:i,userCode:/[A-Z0-9]{4}-[A-Z0-9]{4,5}/.exec(c)?.[0]}}),C({providerId:t,methodIndex:n,methodID:o,attemptID:r,mode:i}),i===`code`&&y(null),a&&s!==`claude-code`&&kr(a),Y.message(e(`settings.providers.page.toast.completeOAuthInBrowser`))},onSuccess:async()=>{if(C(null),D({}),T({}),await tt({scopes:[`providers`],mode:`active`}),!l.isCurrent()||U.current!==l)return;let n=await f.refetch({throwOnError:!0});if(!l.isCurrent()||U.current!==l)return;Y.success(e(`settings.providers.page.toast.oauthCompleted`));let i=n.data?.providers.find(e=>e.id===t)??(s===c?n.data?.providers.find(e=>e.integrationID===s):void 0);i&&r(i.id),y(null)},onError:t=>{y(null),C(null),D({}),T({}),Y.error(e(t===`start`?`settings.providers.page.toast.oauthStartFailed`:`settings.providers.page.toast.oauthCompleteFailed`))}});U.current=l,await l.start(o)}),ie=Ae(async(e,t)=>{let n=`${e}:${t}`,r=w[n]?.trim();!r||S?.mode!==`code`||S.providerId!==e||S.methodIndex!==t||(y(`oauth-complete:${e}:${t}`),await U.current?.complete(r))}),ae=async t=>{if((await je(t)).ok){Y.success(e(`settings.providers.page.toast.oauthLinkCopied`));return}Y.error(e(`settings.providers.page.toast.oauthLinkCopyFailed`))},oe=async t=>{if((await je(t)).ok){Y.success(e(`settings.providers.page.toast.deviceCodeCopied`));return}Y.error(e(`settings.providers.page.toast.deviceCodeCopyFailed`))},se=Ae(async t=>{let n=H();if(!n)return;let r=`disconnect:${t}`;y(r);try{let r=pe.getSdkClient(),i=m[t]||t,a=await r.integration.get({integrationID:i,location:n.location},{signal:n.signal});if(!n.isCurrent())return;let o=(Array.isArray(a.data?.connections)?a.data.connections:[]).flatMap(e=>e.type===`credential`&&typeof e.id==`string`&&e.id?[e.id]:[]);if(o.length===0)throw Error(e(`settings.providers.page.toast.providerDisconnectFailed`));if(await Promise.all(o.map(e=>r.credential.remove({credentialID:e},{signal:n.signal}))),!n.isCurrent()||(await tt({scopes:[`providers`],mode:`active`,queryDirectory:n.directory,transportIdentity:n.transportIdentity}),!n.isCurrent())||(await f.refetch({throwOnError:!0}),!n.isCurrent()))return;Y.success(e(`settings.providers.page.toast.providerDisconnected`))}catch{n.isCurrent()&&Y.error(e(`settings.providers.page.toast.providerDisconnectFailed`))}finally{n.isCurrent()&&y(null)}});if(!B&&t.length===0)return(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,$.jsxs)(`div`,{className:`text-center text-muted-foreground`,children:[(0,$.jsx)(X,{name:`stack`,className:`mx-auto mb-3 h-12 w-12 opacity-50`}),(0,$.jsx)(`p`,{className:`typography-body`,children:e(`settings.providers.page.empty.noProvidersDetected`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 opacity-75`,children:e(`settings.providers.page.empty.checkOpenCodeConfiguration`)})]})});if(B)return(0,$.jsx)(Sr,{outerClassName:`h-full`,className:`w-full`,children:(0,$.jsxs)(`div`,{className:`oc-settings-section-stack mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8`,children:[(0,$.jsx)(`div`,{"data-settings-item":`providers.connect`,children:(0,$.jsx)(`h1`,{className:`typography-ui-header font-semibold text-foreground`,children:e(`settings.providers.page.connect.title`)})}),(0,$.jsxs)(yf,{label:e(`settings.providers.page.connect.selectProviderTitle`),children:[k&&(0,$.jsx)(`p`,{role:`alert`,className:`typography-meta text-muted-foreground`,children:k}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 py-1.5`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e(`settings.providers.page.connect.providerField`)}),O?(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:e(`settings.providers.page.state.loading`)}):k&&!f.data?(0,$.jsx)(J,{variant:`outline`,size:`xs`,onClick:()=>void f.refetch(),children:e(`settings.providers.page.actions.reconnect`)}):ee.length===0?(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:e(`settings.providers.page.connect.allProvidersConnected`)}):(0,$.jsxs)(cr,{open:P,onOpenChange:e=>{F(e),e||N(``)},children:[(0,$.jsx)(mr,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,className:q(`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:[(0,$.jsxs)(`span`,{className:`flex items-center gap-2 min-w-0`,children:[A?(0,$.jsx)(en,{providerId:A,className:`h-3.5 w-3.5 flex-shrink-0`}):null,(0,$.jsx)(`span`,{className:q(`truncate typography-ui-label font-normal`,A?`text-foreground`:`text-muted-foreground`),children:A?ee.find(e=>e.id===A)?.name||A:e(`settings.providers.page.connect.selectProviderPlaceholder`)})]}),(0,$.jsx)(X,{name:`arrow-down-s`,className:`h-4 w-4 flex-shrink-0 text-muted-foreground/50`})]})}),(0,$.jsxs)(Qn,{align:`start`,className:`w-[280px] p-0`,onCloseAutoFocus:e=>e.preventDefault(),children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-[var(--surface-subtle)] px-3 py-2`,onKeyDown:e=>e.stopPropagation(),children:[(0,$.jsx)(X,{name:`search`,className:`h-4 w-4 text-muted-foreground`}),(0,$.jsx)(`input`,{type:`text`,value:M,onChange:e=>N(e.target.value),onKeyDown:e=>e.stopPropagation(),placeholder:e(`settings.providers.page.connect.searchProvidersPlaceholder`),className:`flex-1 bg-transparent typography-meta outline-none placeholder:text-muted-foreground`,autoFocus:!0})]}),(0,$.jsx)(Sr,{outerClassName:`max-h-[240px]`,className:`p-1`,children:(()=>{let t=ee.filter(e=>{let t=M.toLowerCase();return(e.name||e.id).toLowerCase().includes(t)||e.id.toLowerCase().includes(t)});return t.length===0?(0,$.jsx)(`p`,{className:`py-4 text-center typography-meta text-muted-foreground`,children:e(`settings.providers.page.connect.noProvidersFound`)}):t.map(e=>(0,$.jsxs)(Wn,{onSelect:()=>{j(e.id),F(!1),N(``)},className:`flex items-center justify-between`,children:[(0,$.jsxs)(`span`,{className:`flex items-center gap-2 min-w-0`,children:[(0,$.jsx)(en,{providerId:e.id,className:`h-4 w-4 flex-shrink-0`}),(0,$.jsx)(`span`,{className:`truncate`,children:e.name||e.id})]}),A===e.id&&(0,$.jsx)(X,{name:`check`,className:`h-4 w-4 text-[var(--primary-base)]`})]},e.id))})()})]})]})]})]}),A&&(0,$.jsx)(yf,{itemId:`providers.auth`,label:e(`settings.providers.page.auth.title`),children:h?(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:e(`settings.providers.page.auth.loadingMethods`)}):(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`py-1.5`,children:[(0,$.jsxs)(`label`,{className:`typography-ui-label text-foreground flex items-center gap-1.5`,children:[e(`settings.providers.page.auth.apiKeyLabel`),(0,$.jsxs)(hn,{children:[(0,$.jsx)(pn,{asChild:!0,children:(0,$.jsx)(X,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(mn,{sideOffset:8,className:`max-w-xs`,children:e(`settings.providers.page.auth.apiKeyTooltip`)})]})]}),(0,$.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-center gap-2 mt-1.5`,children:[(0,$.jsx)(fn,{type:`password`,value:g[A]??``,onChange:e=>_(t=>({...t,[A]:e.target.value})),placeholder:e(`settings.providers.page.auth.apiKeyPlaceholder`),className:`flex-1 font-mono text-xs`}),(0,$.jsx)(J,{size:`xs`,className:`!font-normal shrink-0`,onClick:()=>ne(A),disabled:v===`api:${A}`,children:v===`api:${A}`?e(`settings.providers.page.actions.saving`):e(`settings.providers.page.actions.saveKey`)})]})]}),(()=>{let t=cf(gf(A,p),e=>Cf(e)===`oauth`);return t.length===0?null:(0,$.jsx)(`div`,{className:`space-y-4 border-t border-[var(--surface-subtle)] pt-2`,children:t.map(({method:t,methodIndex:n},r)=>{let i=t.label||t.name||e(`settings.providers.page.auth.oauthMethodFallback`,{index:String(r+1)}),a=`${A}:${n}`,o=S?.providerId===A&&S?.methodIndex===n;return(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:i}),(t.description||t.help)&&(0,$.jsx)(`div`,{className:`typography-meta text-muted-foreground`,children:String(t.description||t.help)})]}),(0,$.jsx)(J,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>re(A,n),disabled:v===`oauth:${A}:${n}`||v===`oauth-complete:${A}:${n}`,children:o&&S.mode===`auto`?e(`settings.providers.page.state.loading`):e(`settings.providers.page.actions.connect`)}),o&&(0,$.jsx)(J,{variant:`ghost`,size:`xs`,onClick:W,children:e(`settings.common.actions.cancel`)})]}),E[a]?.instructions&&(0,$.jsx)(`p`,{className:`typography-meta text-[var(--primary-base)] bg-[var(--primary-base)]/10 px-2 py-1.5 rounded`,children:E[a]?.instructions}),E[a]?.userCode&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 mt-2`,children:[(0,$.jsx)(fn,{value:E[a]?.userCode,readOnly:!0,className:`font-mono text-center tracking-widest`}),(0,$.jsx)(J,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>oe(E[a]?.userCode??``),children:e(`settings.providers.page.actions.copyCode`)})]}),E[a]?.url&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 mt-2`,children:[(0,$.jsx)(fn,{value:E[a]?.url,readOnly:!0,className:`text-xs text-muted-foreground`}),(0,$.jsxs)(`div`,{className:`flex gap-1 shrink-0`,children:[(0,$.jsx)(J,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>kr(E[a]?.url??``),children:e(`settings.providers.page.actions.open`)}),(0,$.jsx)(J,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>ae(E[a]?.url??``),children:e(`settings.providers.page.actions.copy`)})]})]}),o&&S?.mode===`code`&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 mt-2`,children:[(0,$.jsx)(fn,{value:w[a]??``,onChange:e=>T(t=>({...t,[a]:e.target.value})),placeholder:e(`settings.providers.page.auth.pasteAuthorizationCodePlaceholder`),className:`font-mono text-xs`}),(0,$.jsx)(J,{size:`xs`,className:`!font-normal`,onClick:()=>ie(A,n),disabled:v===`oauth-complete:${A}:${n}`,children:v===`oauth-complete:${A}:${n}`?e(`settings.providers.page.actions.saving`):e(`settings.providers.page.actions.complete`)})]})]},`${A}-${i}`)})})})()]})})]})});if(!G)return(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,$.jsxs)(`div`,{className:`text-center text-muted-foreground`,children:[(0,$.jsx)(X,{name:`stack`,className:`mx-auto mb-3 h-12 w-12 opacity-50`}),(0,$.jsx)(`p`,{className:`typography-body`,children:e(`settings.providers.page.empty.selectProviderFromSidebar`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 opacity-75`,children:e(`settings.providers.page.empty.reviewDetailsAndConfigureAuth`)})]})});let ce=Array.isArray(G.models)?G.models:[],le=cf(gf(G.id,p),e=>Cf(e)===`oauth`),ue=ce.filter(e=>{let t=typeof e?.name==`string`?e.name:``,n=typeof e?.id==`string`?e.id:``,r=b.trim().toLowerCase();return!r||t.toLowerCase().includes(r)||n.toLowerCase().includes(r)});return(0,$.jsx)(Sr,{outerClassName:`h-full`,className:`w-full`,children:(0,$.jsxs)(`div`,{className:`oc-settings-section-stack mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(en,{providerId:G.id,className:`h-5 w-5 shrink-0`}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`h2`,{className:`typography-ui-header font-semibold text-foreground truncate`,children:G.name||G.id}),(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground truncate`,children:(0,$.jsx)(`span`,{className:`font-mono`,children:G.id})})]})]}),(0,$.jsx)(yf,{itemId:`providers.auth`,label:e(`settings.providers.page.auth.title`),action:(0,$.jsx)(J,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>{W(),z(e=>!e)},children:e(R?`settings.providers.page.actions.hide`:`settings.providers.page.actions.reconnect`)}),children:R?h?(0,$.jsx)(`div`,{className:`py-1.5 typography-meta text-muted-foreground`,children:e(`settings.providers.page.auth.loadingMethods`)}):(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`py-1.5`,children:[(0,$.jsxs)(`label`,{className:`typography-ui-label text-foreground flex items-center gap-1.5`,children:[e(`settings.providers.page.auth.apiKeyLabel`),(0,$.jsxs)(hn,{children:[(0,$.jsx)(pn,{asChild:!0,children:(0,$.jsx)(X,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(mn,{sideOffset:8,className:`max-w-xs`,children:e(`settings.providers.page.auth.apiKeyTooltip`)})]})]}),(0,$.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-center gap-2 mt-1.5`,children:[(0,$.jsx)(fn,{type:`password`,value:g[G.id]??``,onChange:e=>_(t=>({...t,[G.id]:e.target.value})),placeholder:e(`settings.providers.page.auth.apiKeyPlaceholder`),className:`flex-1 font-mono text-xs`}),(0,$.jsx)(J,{size:`xs`,className:`!font-normal shrink-0`,onClick:()=>ne(G.id),disabled:v===`api:${G.id}`,children:v===`api:${G.id}`?e(`settings.providers.page.actions.saving`):e(`settings.providers.page.actions.saveKey`)})]})]}),le.length>0&&(0,$.jsx)(`div`,{className:`space-y-4 border-t border-[var(--surface-subtle)] pt-2`,children:le.map(({method:t,methodIndex:n},r)=>{let i=t.label||t.name||e(`settings.providers.page.auth.oauthMethodFallback`,{index:String(r+1)}),a=`${G.id}:${n}`,o=S?.providerId===G.id&&S?.methodIndex===n;return(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:i}),(t.description||t.help)&&(0,$.jsx)(`div`,{className:`typography-meta text-muted-foreground`,children:String(t.description||t.help)})]}),(0,$.jsx)(J,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>re(G.id,n),disabled:v===`oauth:${G.id}:${n}`||v===`oauth-complete:${G.id}:${n}`,children:o&&S.mode===`auto`?e(`settings.providers.page.state.loading`):e(`settings.providers.page.actions.connect`)}),o&&(0,$.jsx)(J,{variant:`ghost`,size:`xs`,onClick:W,children:e(`settings.common.actions.cancel`)})]}),E[a]?.instructions&&(0,$.jsx)(`p`,{className:`typography-meta text-[var(--primary-base)] bg-[var(--primary-base)]/10 px-2 py-1.5 rounded`,children:E[a]?.instructions}),E[a]?.userCode&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 mt-2`,children:[(0,$.jsx)(fn,{value:E[a]?.userCode,readOnly:!0,className:`font-mono text-center tracking-widest`}),(0,$.jsx)(J,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>oe(E[a]?.userCode??``),children:e(`settings.providers.page.actions.copyCode`)})]}),E[a]?.url&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 mt-2`,children:[(0,$.jsx)(fn,{value:E[a]?.url,readOnly:!0,className:`text-xs text-muted-foreground`}),(0,$.jsxs)(`div`,{className:`flex gap-1 shrink-0`,children:[(0,$.jsx)(J,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>kr(E[a]?.url??``),children:e(`settings.providers.page.actions.open`)}),(0,$.jsx)(J,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>ae(E[a]?.url??``),children:e(`settings.providers.page.actions.copy`)})]})]}),o&&S?.mode===`code`&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 mt-2`,children:[(0,$.jsx)(fn,{value:w[a]??``,onChange:e=>T(t=>({...t,[a]:e.target.value})),placeholder:e(`settings.providers.page.auth.pasteAuthorizationCodePlaceholder`),className:`font-mono text-xs`}),(0,$.jsx)(J,{size:`xs`,className:`!font-normal`,onClick:()=>ie(G.id,n),disabled:v===`oauth-complete:${G.id}:${n}`,children:v===`oauth-complete:${G.id}:${n}`?e(`settings.providers.page.actions.saving`):e(`settings.providers.page.actions.complete`)})]})]},`${G.id}-${i}`)})})]}):(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 py-1.5`,children:[(0,$.jsx)(X,{name:`check`,className:`w-4 h-4 text-[var(--status-success)] shrink-0`}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e(`settings.providers.page.auth.connected`)}),(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground ml-1`,children:e(`settings.providers.page.auth.useReconnectHint`)})]})}),(G.id===`opencode`||G.id===`opencode-go`)&&(0,$.jsx)(vf,{providerId:`opencode-go`,providerName:`OpenCode Go`}),(G.id===`ollama`||G.id===`ollama-cloud`)&&(0,$.jsx)(vf,{providerId:`ollama-cloud`,providerName:`Ollama Cloud`}),G.id===`cursor`&&(0,$.jsx)(vf,{providerId:`cursor`,providerName:`Cursor`}),(0,$.jsx)(yf,{itemId:`providers.connection-details`,label:e(`settings.providers.page.connectionDetails.title`),children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 py-1.5 sm:flex-row sm:items-center sm:justify-between sm:gap-8`,children:[(0,$.jsx)(`div`,{className:`flex min-w-0 flex-col`,children:te&&(te.auth.exists||te.user.exists||te.project.exists||te.custom?.exists)?(0,$.jsxs)(`span`,{className:`typography-meta text-muted-foreground`,children:[e(`settings.providers.page.connectionDetails.configuredIn`),` `,[te.auth.exists?e(`settings.providers.page.connectionDetails.source.authCredentials`):null,te.user.exists?e(`settings.providers.page.connectionDetails.source.userConfig`):null,te.project.exists?e(`settings.providers.page.connectionDetails.source.projectConfig`):null,te.custom?.exists?e(`settings.providers.page.connectionDetails.source.customConfig`):null].filter(Boolean).join(`, `)]}):(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:e(`settings.providers.page.connectionDetails.noActiveSource`)})}),(0,$.jsx)(J,{variant:`ghost`,size:`xs`,className:`!font-normal text-[var(--status-error)] hover:text-[var(--status-error)]`,onClick:()=>se(G.id),disabled:v===`disconnect:${G.id}`,children:v===`disconnect:${G.id}`?e(`settings.providers.page.actions.disconnecting`):e(`settings.providers.page.actions.disconnect`)})]})}),(0,$.jsxs)(yf,{itemId:`providers.models`,label:(0,$.jsxs)($.Fragment,{children:[e(`settings.providers.page.models.title`),ce.length>0&&(0,$.jsxs)(`span`,{className:`ml-1.5 typography-micro text-muted-foreground font-normal`,children:[`(`,ce.length,`)`]})]}),action:(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(J,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>{let e=ce.map(e=>typeof e?.id==`string`?e.id:``).filter(e=>e.length>0);u(G.id,e)},children:e(`settings.providers.page.actions.hideAll`)}),(0,$.jsx)(J,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>d(G.id),children:e(`settings.providers.page.actions.showAll`)})]}),children:[(0,$.jsxs)(`div`,{className:`relative mb-2`,children:[(0,$.jsx)(X,{name:`search`,className:`absolute left-2 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground`}),(0,$.jsx)(fn,{value:b,onChange:e=>x(e.target.value),placeholder:e(`settings.providers.page.models.filterPlaceholder`),className:`h-7 pl-8 w-full`})]}),ue.length===0?(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground py-4 text-center`,children:e(`settings.providers.page.models.noModelsMatchFilter`)}):(0,$.jsx)(`div`,{className:`divide-y divide-[var(--surface-subtle)]`,children:ue.map(t=>{let n=typeof t?.id==`string`?t.id:``,r=typeof t?.name==`string`?t.name:n,i=n?a(G.id,n):void 0,o=s.some(e=>e.providerID===G.id&&e.modelID===n),l=xf(i?.limit?.context),u=xf(i?.limit?.output),d=[];return i?.tool_call&&d.push({key:`tools`,icon:`tools`,label:e(`settings.providers.page.models.capability.toolCalling`)}),i?.reasoning&&d.push({key:`reasoning`,icon:`brain-ai-3`,label:e(`settings.providers.page.models.capability.reasoning`)}),i?.attachment&&d.push({key:`image`,icon:`file-image`,label:e(`settings.providers.page.models.capability.imageInput`)}),(0,$.jsx)(`div`,{className:`py-1.5`,children:(0,$.jsxs)(`div`,{className:q(`flex flex-wrap items-center gap-x-3 gap-y-1.5 md:flex-nowrap md:gap-3`,o&&`opacity-50`),children:[(0,$.jsx)(`span`,{className:`typography-meta font-medium text-foreground truncate w-full min-w-0 md:w-auto md:flex-1`,children:r}),(0,$.jsxs)(`div`,{className:`flex w-full flex-wrap items-center gap-2 flex-shrink-0 md:w-auto md:flex-nowrap`,children:[(l||u)&&(0,$.jsxs)(`span`,{className:`typography-micro text-muted-foreground flex-shrink-0 bg-[var(--surface-muted)] px-1.5 py-0.5 rounded`,children:[l?`${l} ${e(`settings.providers.page.models.tokenBadge.context`)}`:``,l&&u?` · `:``,u?`${u} ${e(`settings.providers.page.models.tokenBadge.output`)}`:``]}),d.length>0&&(0,$.jsx)(`div`,{className:`flex items-center gap-1 flex-shrink-0`,children:d.map(({key:e,icon:t,label:n})=>(0,$.jsx)(`span`,{className:`flex h-5 w-5 rounded items-center justify-center text-muted-foreground bg-[var(--surface-muted)]`,title:n,"aria-label":n,children:(0,$.jsx)(X,{name:t,className:`h-3 w-3`})},e))}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>c(G.id,n),className:`ml-auto flex h-6 w-6 items-center justify-center rounded text-muted-foreground hover:text-foreground hover:bg-[var(--interactive-hover)]/50 md:ml-0`,title:e(o?`settings.providers.page.models.actions.showModelInSelectors`:`settings.providers.page.models.actions.hideModelFromSelectors`),"aria-label":e(o?`settings.providers.page.models.actions.showModel`:`settings.providers.page.models.actions.hideModel`),children:o?(0,$.jsx)(X,{name:`eye-off`,className:`h-3.5 w-3.5`}):(0,$.jsx)(X,{name:`eye`,className:`h-3.5 w-3.5`})})]})]})},n)})})]})]})})};function Of(e){return e.currentDirectory}var kf=e=>{let t=e?.windows??{},n=Object.values(t).map(e=>e.usedPercent).filter(e=>typeof e==`number`);return n.length===0?null:Math.max(...n)},Af=e=>{let t=(0,Ii.c)(112),{onItemSelect:n}=e,{t:r}=Me(),i=_i(jf),a=_i(Mf),o=_i(Nf),s=_i(Pf),c=_i(Ff),l=_i(If),u=_i(Lf),d=_i(Rf),f=_i(zf),p=_i(Bf),m=_i(Vf),h=_i(Hf),g=_i(Uf),_=_i(Wf),v,y;t[0]===_?(v=t[1],y=t[2]):(v=()=>{_()},y=[_],t[0]=_,t[1]=v,t[2]=y),Q.useEffect(v,y);let b=Gf,x;t[3]===f?x=t[4]:(x=e=>{f(e),b({usageAutoRefresh:e})},t[3]=f,t[4]=x);let S=x,C;t[5]===p?C=t[6]:(C=e=>{let t=Number(e);Number.isFinite(t)&&(p(t),b({usageRefreshIntervalMs:t}))},t[5]=p,t[6]=C);let w=C,T;t[7]===m?T=t[8]:(T=e=>{(e===`usage`||e===`remaining`)&&(m(e),b({usageDisplayMode:e}))},t[7]=m,t[8]=T);let E=T,D;t[9]===g?D=t[10]:(D=e=>{g(e),b({usageShowPredValues:e})},t[9]=g,t[10]=D);let O=D,k;t[11]===r?k=t[12]:(k=r(`settings.usage.sidebar.title`),t[11]=r,t[12]=k);let A;t[13]===s?A=t[14]:(A=()=>s(),t[13]=s,t[14]=A);let j;t[15]===r?j=t[16]:(j=r(`settings.usage.sidebar.actions.refreshAria`),t[15]=r,t[16]=j);let M;t[17]===r?M=t[18]:(M=r(`settings.usage.sidebar.actions.refreshTitle`),t[17]=r,t[18]=M);let N=c&&`animate-spin`,P;t[19]===N?P=t[20]:(P=q(`h-3.5 w-3.5`,N),t[19]=N,t[20]=P);let F;t[21]===P?F=t[22]:(F=(0,$.jsx)(X,{name:`refresh`,className:P}),t[21]=P,t[22]=F);let I;t[23]!==c||t[24]!==M||t[25]!==F||t[26]!==A||t[27]!==j?(I=(0,$.jsx)(J,{size:`icon`,variant:`ghost`,className:`text-muted-foreground`,onClick:A,"aria-label":j,title:M,disabled:c,children:F}),t[23]=c,t[24]=M,t[25]=F,t[26]=A,t[27]=j,t[28]=I):I=t[28];let L;t[29]!==I||t[30]!==k?(L=(0,$.jsx)(Nr,{label:k,children:I}),t[29]=I,t[30]=k,t[31]=L):L=t[31];let R;t[32]===r?R=t[33]:(R=r(`settings.usage.sidebar.field.autoRefresh`),t[32]=r,t[33]=R);let z;t[34]===r?z=t[35]:(z=r(`settings.usage.sidebar.actions.toggleAutoRefreshAria`),t[34]=r,t[35]=z);let B;t[36]!==S||t[37]!==z||t[38]!==l?(B=(0,$.jsx)(sn,{checked:l,onChange:S,ariaLabel:z}),t[36]=S,t[37]=z,t[38]=l,t[39]=B):B=t[39];let V;t[40]!==R||t[41]!==B?(V=(0,$.jsx)(Nr,{label:R,children:B}),t[40]=R,t[41]=B,t[42]=V):V=t[42];let H;t[43]===r?H=t[44]:(H=r(`settings.usage.sidebar.field.refreshInterval`),t[43]=r,t[44]=H);let U=String(u),W=!l,ee;t[45]===r?ee=t[46]:(ee=r(`settings.usage.sidebar.field.intervalPlaceholder`),t[45]=r,t[46]=ee);let G;t[47]===ee?G=t[48]:(G=(0,$.jsx)(rn,{className:`w-fit`,children:(0,$.jsx)(dn,{placeholder:ee,children:Kf})}),t[47]=ee,t[48]=G);let te;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(te=(0,$.jsxs)(an,{children:[(0,$.jsx)(tn,{value:`30000`,children:`30s`}),(0,$.jsx)(tn,{value:`60000`,children:`1m`}),(0,$.jsx)(tn,{value:`300000`,children:`5m`})]}),t[49]=te):te=t[49];let ne;t[50]!==w||t[51]!==U||t[52]!==W||t[53]!==G?(ne=(0,$.jsxs)(ln,{value:U,onValueChange:w,disabled:W,children:[G,te]}),t[50]=w,t[51]=U,t[52]=W,t[53]=G,t[54]=ne):ne=t[54];let re;t[55]!==H||t[56]!==ne?(re=(0,$.jsx)(Nr,{label:H,children:ne}),t[55]=H,t[56]=ne,t[57]=re):re=t[57];let ie;t[58]===r?ie=t[59]:(ie=r(`settings.usage.sidebar.field.display`),t[58]=r,t[59]=ie);let ae;t[60]===r?ae=t[61]:(ae=r(`settings.usage.sidebar.field.displayModePlaceholder`),t[60]=r,t[61]=ae);let oe;t[62]===r?oe=t[63]:(oe=e=>e===`usage`?r(`settings.usage.sidebar.field.displayModeUsage`):e===`remaining`?r(`settings.usage.sidebar.field.displayModeRemaining`):e,t[62]=r,t[63]=oe);let se;t[64]!==ae||t[65]!==oe?(se=(0,$.jsx)(rn,{className:`w-fit`,children:(0,$.jsx)(dn,{placeholder:ae,children:oe})}),t[64]=ae,t[65]=oe,t[66]=se):se=t[66];let ce;t[67]===r?ce=t[68]:(ce=r(`settings.usage.sidebar.field.displayModeUsage`),t[67]=r,t[68]=ce);let le;t[69]===ce?le=t[70]:(le=(0,$.jsx)(tn,{value:`usage`,children:ce}),t[69]=ce,t[70]=le);let ue;t[71]===r?ue=t[72]:(ue=r(`settings.usage.sidebar.field.displayModeRemaining`),t[71]=r,t[72]=ue);let de;t[73]===ue?de=t[74]:(de=(0,$.jsx)(tn,{value:`remaining`,children:ue}),t[73]=ue,t[74]=de);let fe;t[75]!==le||t[76]!==de?(fe=(0,$.jsxs)(an,{children:[le,de]}),t[75]=le,t[76]=de,t[77]=fe):fe=t[77];let pe;t[78]!==E||t[79]!==se||t[80]!==fe||t[81]!==d?(pe=(0,$.jsxs)(ln,{value:d,onValueChange:E,children:[se,fe]}),t[78]=E,t[79]=se,t[80]=fe,t[81]=d,t[82]=pe):pe=t[82];let me;t[83]!==ie||t[84]!==pe?(me=(0,$.jsx)(Nr,{label:ie,children:pe}),t[83]=ie,t[84]=pe,t[85]=me):me=t[85];let he;t[86]===r?he=t[87]:(he=r(`settings.usage.sidebar.field.showPredictions`),t[86]=r,t[87]=he);let ge;t[88]===r?ge=t[89]:(ge=r(`settings.usage.sidebar.field.showPredictions`),t[88]=r,t[89]=ge);let _e;t[90]!==O||t[91]!==h||t[92]!==he||t[93]!==ge?(_e=(0,$.jsx)(Qr,{checked:h,onChange:O,label:he,ariaLabel:ge}),t[90]=O,t[91]=h,t[92]=he,t[93]=ge,t[94]=_e):_e=t[94];let ve;t[95]!==L||t[96]!==V||t[97]!==re||t[98]!==me||t[99]!==_e?(ve=(0,$.jsxs)(vi,{children:[L,V,re,me,_e]}),t[95]=L,t[96]=V,t[97]=re,t[98]=me,t[99]=_e,t[100]=ve):ve=t[100];let K;t[101]!==n||t[102]!==i||t[103]!==a||t[104]!==o||t[105]!==r?(K=ei.map(e=>{let t=i.find(t=>t?.providerId===e.id),s=kf(t?.usage),c=An(s),l=e.id===a,u=t?.configured??!1,d=u?c===`critical`?{backgroundColor:`var(--status-error)`}:c===`warn`?{backgroundColor:`var(--status-warning)`}:{backgroundColor:`var(--status-success)`}:{backgroundColor:`var(--surface-muted-foreground)`,opacity:.4};return(0,$.jsx)(`div`,{className:q(`oc-settings-group-row group relative flex items-center transition-colors duration-150`,l?`bg-interactive-selection`:`hover:bg-interactive-hover`),children:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{o(e.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:[(0,$.jsx)(`span`,{className:`h-2.5 w-2.5 rounded-full flex-shrink-0`,style:d}),(0,$.jsx)(en,{providerId:e.id,className:`h-4 w-4 flex-shrink-0`}),(0,$.jsx)(`span`,{className:`typography-ui-label font-normal truncate flex-1 min-w-0 text-foreground`,children:e.name}),!u&&(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground/60 flex-shrink-0`,children:r(`settings.usage.sidebar.status.notSet`)})]})},e.id)}),t[101]=n,t[102]=i,t[103]=a,t[104]=o,t[105]=r,t[106]=K):K=t[106];let ye;t[107]===K?ye=t[108]:(ye=(0,$.jsx)(vi,{children:K}),t[107]=K,t[108]=ye);let be;return t[109]!==ve||t[110]!==ye?(be=(0,$.jsxs)(`div`,{className:`oc-settings-page-content oc-settings-usage-sidebar h-full overflow-y-auto bg-background p-3`,children:[ve,ye]}),t[109]=ve,t[110]=ye,t[111]=be):be=t[111],be};function jf(e){return e.results}function Mf(e){return e.selectedProviderId}function Nf(e){return e.setSelectedProvider}function Pf(e){return e.fetchAllQuotas}function Ff(e){return e.isLoading}function If(e){return e.autoRefresh}function Lf(e){return e.refreshIntervalMs}function Rf(e){return e.displayMode}function zf(e){return e.setAutoRefresh}function Bf(e){return e.setRefreshInterval}function Vf(e){return e.setDisplayMode}function Hf(e){return e.showPredValues}function Uf(e){return e.setShowPredValues}function Wf(e){return e.loadSettings}async function Gf(e){try{await M(e)}catch(e){console.warn(`Failed to save usage settings:`,e)}}function Kf(e){return e===`30000`?`30s`:e===`60000`?`1m`:e===`300000`?`5m`:e}var qf=e=>{let t=(0,Ii.c)(54),{title:n,window:r,subtitle:i,showToggle:a,toggleEnabled:o,onToggle:s}=e,c=a!==void 0&&a,l=o!==void 0&&o,u=_i(Jf),d=_i(Yf),f=K(Xf),p=u===`remaining`?r.remainingPercent:r.usedPercent,m=u===`remaining`?`remaining`:`used`,h;t[0]!==p||t[1]!==r.valueLabel?(h=tr(r.valueLabel,p),t[0]=p,t[1]=r.valueLabel,t[2]=h):h=t[2];let g=h,_=r.resetAfterFormatted??r.resetAtFormatted,v;t[3]!==_||t[4]!==f||t[5]!==r.resetAt?(v=Mn(r.resetAt,_,f),t[3]=_,t[4]=f,t[5]=r.resetAt,t[6]=v):v=t[6];let y=v,b;t[7]===n?b=t[8]:(b=$n(n),t[7]=n,t[8]=b);let x=b,S;t[9]!==n||t[10]!==r.resetAt||t[11]!==r.usedPercent||t[12]!==r.windowSeconds?(S=yn(r.usedPercent,r.resetAt,r.windowSeconds,n),t[9]=n,t[10]=r.resetAt,t[11]=r.usedPercent,t[12]=r.windowSeconds,t[13]=S):S=t[13];let C=S,w;bb0:{if(!C||C.dailyAllocationPercent===null){w=null;break bb0}let e=Ln(C.elapsedRatio);w=u===`remaining`?100-e:e}let T=w,E;t[14]!==s||t[15]!==c||t[16]!==l?(E=c&&(0,$.jsx)(sn,{checked:l,onChange:e=>s?.(e),ariaLabel:`Show in dropdown`}),t[14]=s,t[15]=c,t[16]=l,t[17]=E):E=t[17];let D;t[18]===x?D=t[19]:(D=(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground truncate`,children:x}),t[18]=x,t[19]=D);let O;t[20]===i?O=t[21]:(O=i&&(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground truncate`,children:i}),t[20]=i,t[21]=O);let k;t[22]!==D||t[23]!==O?(k=(0,$.jsxs)(`div`,{className:`min-w-0 flex flex-col`,children:[D,O]}),t[22]=D,t[23]=O,t[24]=k):k=t[24];let A;t[25]!==k||t[26]!==E?(A=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 flex items-center gap-2`,children:[E,k]}),t[25]=k,t[26]=E,t[27]=A):A=t[27];let j=g===`-`?``:g,M;t[28]===j?M=t[29]:(M=(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground tabular-nums flex items-center justify-end`,children:j}),t[28]=j,t[29]=M);let N;t[30]!==A||t[31]!==M?(N=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[A,M]}),t[30]=A,t[31]=M,t[32]=N):N=t[32];let P;t[33]!==p||t[34]!==T||t[35]!==r.usedPercent?(P=(0,$.jsx)(gi,{percent:p,tonePercent:r.usedPercent,expectedMarkerPercent:T,className:`h-1.5`}),t[33]=p,t[34]=T,t[35]=r.usedPercent,t[36]=P):P=t[36];let F=y?`Resets ${y}`:``,I;t[37]===F?I=t[38]:(I=(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:F}),t[37]=F,t[38]=I);let L;t[39]===m?L=t[40]:(L=(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:m}),t[39]=m,t[40]=L);let R;t[41]!==I||t[42]!==L?(R=(0,$.jsxs)(`div`,{className:`mt-1 flex items-center justify-between`,children:[I,L]}),t[41]=I,t[42]=L,t[43]=R):R=t[43];let z;t[44]!==P||t[45]!==R?(z=(0,$.jsxs)(`div`,{className:`mt-2.5`,children:[P,R]}),t[44]=P,t[45]=R,t[46]=z):z=t[46];let B;t[47]!==C||t[48]!==d?(B=C&&d&&(0,$.jsx)(`div`,{className:`mt-1.5`,children:(0,$.jsx)(ti,{paceInfo:C})}),t[47]=C,t[48]=d,t[49]=B):B=t[49];let V;return t[50]!==N||t[51]!==z||t[52]!==B?(V=(0,$.jsxs)(`div`,{className:`py-3`,children:[N,z,B]}),t[50]=N,t[51]=z,t[52]=B,t[53]=V):V=t[53],V};function Jf(e){return e.displayMode}function Yf(e){return e.showPredValues}function Xf(e){return e.timeFormatPreference}var Zf=(e,t)=>{if(!e)return`-`;try{return bn(e,t,{fallback:`-`})}catch{return`-`}},Qf=()=>{let{t:e}=Me(),t=K(e=>e.timeFormatPreference),n=_i(e=>e.results),r=_i(e=>e.selectedProviderId),i=_i(e=>e.setSelectedProvider),a=_i(e=>e.loadSettings),o=_i(e=>e.fetchAllQuotas),s=_i(e=>e.isLoading),c=_i(e=>e.lastUpdated),l=_i(e=>e.error),u=_i(e=>e.dropdownProviderIds),d=_i(e=>e.setDropdownProviderIds),f=_i(e=>e.selectedModels),p=_i(e=>e.toggleModelSelected),m=_i(e=>e.applyDefaultSelections);ri(),Q.useEffect(()=>{a(),o()},[a,o]),Q.useEffect(()=>{if(r||n.length===0)return;let e=n.find(e=>e?.configured)?.providerId;i(e??ei[0]?.id??null)},[n,r,i]);let h=n.find(e=>e?.providerId===r)??null,g=ei.find(e=>e.id===r)?.name??r??e(`settings.usage.sidebar.title`),_=h?.usage,v=r?u.includes(r):!1,y=Q.useCallback(e=>{if(!r)return;let t=e?Array.from(new Set([...u,r])):u.filter(e=>e!==r);d(t),M({usageDropdownProviders:t})},[u,r,d]),b=Q.useMemo(()=>_?.models?Object.entries(_.models).map(([e,t])=>({name:e,windows:t})).filter(e=>Object.keys(e.windows.windows).length>0):[],[_?.models]);Q.useEffect(()=>{r&&b.length>0&&m(r,b.map(e=>e.name))},[r,b,m]);let x=Q.useMemo(()=>!r||b.length===0?new Map:Xr(b,e=>e.name,r),[b,r]),S=Q.useMemo(()=>{if(!r)return[];let e=Yr(r);return Ir(e)},[r]),[C,w]=Q.useState(()=>({})),T=Q.useCallback(e=>{w(t=>({...t,[e]:!t[e]}))},[]),E=Q.useCallback(e=>{if(!r)return;p(r,e);let t=f[r]??[],n=t.includes(e)?t.filter(t=>t!==e):[...t,e],i={...f,[r]:n};M({usageSelectedModels:i})},[r,f,p]),D=r?f[r]??[]:[];return r?(0,$.jsx)(Sr,{outerClassName:`h-full`,className:`w-full`,children:(0,$.jsxs)(`div`,{className:`oc-settings-page-content mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(en,{providerId:r,className:`h-5 w-5 shrink-0`}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`h2`,{className:`typography-ui-header font-semibold text-foreground truncate`,children:e(`settings.usage.page.header.providerUsage`,{provider:g})}),(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground truncate`,children:s?(0,$.jsx)(`span`,{className:`animate-pulse`,children:e(`settings.usage.page.header.refreshing`)}):e(`settings.usage.page.header.lastUpdated`,{time:Zf(c,t)})})]})]}),(0,$.jsx)(vi,{children:(0,$.jsxs)(`div`,{"data-settings-item":`usage.header-menu`,className:`oc-settings-group-row oc-settings-split-row group cursor-pointer`,role:`button`,tabIndex:0,"aria-pressed":v,onClick:()=>y(!v),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),y(!v))},children:[(0,$.jsx)(`div`,{className:`oc-settings-split-row-copy`,children:(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e(`settings.usage.page.options.showInHeader`)}),(0,$.jsxs)(hn,{children:[(0,$.jsx)(pn,{asChild:!0,children:(0,$.jsx)(X,{name:`information`,className:`h-3.5 w-3.5 cursor-help text-muted-foreground/60`})}),(0,$.jsx)(mn,{sideOffset:8,className:`max-w-xs`,children:e(`settings.usage.page.options.showInHeaderTooltip`)})]})]})}),(0,$.jsx)(`div`,{"data-settings-value":``,className:`oc-settings-split-row-control`,children:(0,$.jsx)(sn,{checked:v,onChange:y,ariaLabel:e(`settings.usage.page.options.showInHeaderAria`)})})]})}),!h&&(0,$.jsx)(`div`,{className:`px-2`,children:(0,$.jsx)(`p`,{className:`typography-ui-label text-foreground`,children:e(`settings.usage.page.state.noData`)})}),l&&(0,$.jsxs)(`div`,{className:`rounded-lg border border-[var(--status-error-border)] bg-[var(--status-error-background)] px-4 py-3`,children:[(0,$.jsx)(`p`,{className:`typography-ui-label font-medium text-[var(--status-error)]`,children:e(`settings.usage.page.state.refreshFailedTitle`)}),(0,$.jsx)(`p`,{className:`typography-meta text-[var(--status-error)]/80 mt-1`,children:l})]}),h?.configured&&!h.ok&&h.error&&(0,$.jsxs)(`div`,{className:`rounded-lg border border-[var(--status-error-border)] bg-[var(--status-error-background)] px-4 py-3`,children:[(0,$.jsx)(`p`,{className:`typography-ui-label font-medium text-[var(--status-error)]`,children:e(`settings.usage.page.state.refreshFailedTitle`)}),(0,$.jsx)(`p`,{className:`typography-meta text-[var(--status-error)]/80 mt-1`,children:h.error})]}),h&&!h.configured&&(0,$.jsxs)(`div`,{className:`rounded-lg border border-[var(--status-warning-border)] bg-[var(--status-warning-background)] px-4 py-3`,children:[(0,$.jsx)(`p`,{className:`typography-ui-label font-medium text-[var(--status-warning)]`,children:e(`settings.usage.page.state.providerNotConfiguredTitle`)}),(0,$.jsx)(`p`,{className:`typography-meta text-[var(--status-warning)]/80 mt-1`,children:e(`settings.usage.page.state.providerNotConfiguredDescription`)})]}),_?.windows&&Object.keys(_.windows).length>0&&(0,$.jsx)(vi,{children:(0,$.jsx)(`div`,{"data-settings-item":`usage.model-quotas`,className:`oc-settings-group-row`,children:(0,$.jsx)(`div`,{className:`divide-y divide-[var(--surface-subtle)]`,children:Object.entries(_.windows).map(([e,t])=>(0,$.jsx)(qf,{title:e,window:t},e))})})}),b.length>0&&(0,$.jsxs)(vi,{label:e(`settings.usage.page.section.modelQuotas`),children:[S.map(e=>{let t=x.get(e.id)??[];if(t.length===0)return null;let n=C[e.id]??!1;return(0,$.jsx)(`div`,{className:`oc-settings-group-row`,children:(0,$.jsxs)(Mi,{open:!n,onOpenChange:()=>T(e.id),children:[(0,$.jsxs)(ji,{className:`flex w-full items-center justify-between py-0.5 group`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 text-left`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label font-normal text-foreground`,children:e.label}),(0,$.jsxs)(`span`,{className:`typography-micro text-muted-foreground`,children:[`(`,t.length,`)`]})]}),n?(0,$.jsx)(X,{name:`arrow-right-s`,className:`h-4 w-4 text-muted-foreground group-hover:text-foreground transition-colors`}):(0,$.jsx)(X,{name:`arrow-down-s`,className:`h-4 w-4 text-muted-foreground group-hover:text-foreground transition-colors`})]}),(0,$.jsx)(Ai,{children:(0,$.jsx)(`div`,{className:`divide-y divide-[var(--surface-subtle)] mt-1`,children:t.map(e=>{let t=Object.entries(e.windows.windows);if(t.length===0)return null;let[n,r]=t[0],i=D.includes(e.name);return(0,$.jsx)(qf,{title:n,subtitle:Pr(e.name),window:r,showToggle:!0,toggleEnabled:i,onToggle:()=>E(e.name)},e.name)})})})]})},e.id)}),(()=>{let t=x.get(null)??[];if(t.length===0)return null;let n=C.other??!1;return(0,$.jsx)(`div`,{className:`oc-settings-group-row`,children:(0,$.jsxs)(Mi,{open:!n,onOpenChange:()=>T(`other`),children:[(0,$.jsxs)(ji,{className:`flex w-full items-center justify-between py-0.5 group`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 text-left`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label font-normal text-foreground`,children:e(`settings.usage.page.section.otherModels`)}),(0,$.jsxs)(`span`,{className:`typography-micro text-muted-foreground`,children:[`(`,t.length,`)`]})]}),n?(0,$.jsx)(X,{name:`arrow-right-s`,className:`h-4 w-4 text-muted-foreground group-hover:text-foreground transition-colors`}):(0,$.jsx)(X,{name:`arrow-down-s`,className:`h-4 w-4 text-muted-foreground group-hover:text-foreground transition-colors`})]}),(0,$.jsx)(Ai,{children:(0,$.jsx)(`div`,{className:`divide-y divide-[var(--surface-subtle)] mt-1`,children:t.map(e=>{let t=Object.entries(e.windows.windows);if(t.length===0)return null;let[n,r]=t[0],i=D.includes(e.name);return(0,$.jsx)(qf,{title:n,subtitle:Pr(e.name),window:r,showToggle:!0,toggleEnabled:i,onToggle:()=>E(e.name)},e.name)})})})]})})})()]}),h?.configured&&_&&Object.keys(_.windows??{}).length===0&&b.length===0&&(0,$.jsxs)(`div`,{className:`px-2`,children:[(0,$.jsx)(`p`,{className:`typography-ui-label text-foreground`,children:e(`settings.usage.page.state.noQuotaWindowsTitle`)}),(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground mt-1`,children:e(`settings.usage.page.state.noQuotaWindowsDescription`)})]})]})}):(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center text-muted-foreground`,children:(0,$.jsx)(`p`,{className:`typography-body`,children:e(`settings.usage.page.empty.selectProvider`)})})},$f=`git.commit.generate`,ep=oe(e=>({selectedPromptId:$f,setSelectedPromptId:t=>{e(e=>e.selectedPromptId===t?e:{selectedPromptId:t})}})),tp=e=>{let t=(0,Ii.c)(22),{onItemSelect:n}=e,{t:r}=Me(),i=ep(np),a=ep(rp),o;t[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`}]},t[0]=o):o=t[0];let s;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(s={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`}]},t[1]=s):s=t[1];let c;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(c=[o,s,{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.craftGoal`,titleKey:`settings.magicPrompts.sidebar.item.sessionCraftGoal`},{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`}]}],t[2]=c):c=t[2];let l=c,u;t[3]===r?u=t[4]:(u=r(`settings.magicPrompts.sidebar.title`),t[3]=r,t[4]=u);let d;t[5]===u?d=t[6]:(d=(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:u}),t[5]=u,t[6]=d);let f;t[7]===r?f=t[8]:(f=r(`settings.magicPrompts.sidebar.description`),t[7]=r,t[8]=f);let p;t[9]===f?p=t[10]:(p=(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:f}),t[9]=f,t[10]=p);let m;t[11]!==d||t[12]!==p?(m=(0,$.jsxs)(`div`,{className:`flex flex-col justify-center gap-1 px-2`,children:[d,p]}),t[11]=d,t[12]=p,t[13]=m):m=t[13];let h;t[14]!==n||t[15]!==i||t[16]!==a||t[17]!==r?(h=l.map(e=>(0,$.jsx)(vi,{label:r(e.groupKey),children:e.items.map(e=>{let t=i===e.id;return(0,$.jsx)(`button`,{type:`button`,onClick:()=>{a(e.id),n?.()},className:q(`oc-settings-group-row flex w-full items-center text-left transition-colors`,t?`bg-interactive-selection text-foreground`:`text-foreground hover:bg-interactive-hover`),children:(0,$.jsx)(`span`,{className:`typography-ui-label truncate font-normal`,children:r(e.titleKey)})},e.id)})},e.groupKey)),t[14]=n,t[15]=i,t[16]=a,t[17]=r,t[18]=h):h=t[18];let g;return t[19]!==m||t[20]!==h?(g=(0,$.jsxs)(`div`,{className:`oc-settings-page-content h-full overflow-y-auto bg-background p-3`,children:[m,h]}),t[19]=m,t[20]=h,t[21]=g):g=t[21],g};function np(e){return e.selectedPromptId}function rp(e){return e.setSelectedPromptId}var ip={"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`}]},"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.craftGoal":{titleKey:`settings.magicPrompts.page.group.sessionCraftGoal.title`,descriptionKey:`settings.magicPrompts.page.group.sessionCraftGoal.description`,blocks:[{id:`session.craftGoal.visible`,titleKey:`settings.magicPrompts.page.block.visiblePrompt`},{id:`session.craftGoal.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`}]}},ap=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),op=e=>e.endsWith(`.visible`),sp=()=>{let{t:e}=Me(),t=Q.useCallback(t=>e(t),[e]),n=ep(e=>e.selectedPromptId),[r,i]=Q.useState(!0),[a,o]=Q.useState({}),[s,c]=Q.useState({}),[l,u]=Q.useState({}),[d,f]=Q.useState({}),[p,m]=Q.useState(!1);Q.useEffect(()=>{let t=!0;return(async()=>{i(!0);try{let e=await Bt();if(!t)return;o(e)}catch(t){console.warn(`Failed to load magic prompts:`,t),Y.error(e(`settings.magicPrompts.page.toast.loadFailed`))}finally{t&&i(!1)}})(),()=>{t=!1}},[e]);let h=ip[n]??ip[`git.commit.generate`],g=Q.useCallback(e=>ap(a,e)?a[e]:st(e),[a]),_=Q.useCallback(e=>s[e]??g(e),[s,g]),v=Q.useCallback((e,t)=>{c(n=>n[e]===t?n:{...n,[e]:t})},[]),y=Q.useCallback(async t=>{let n=_(t);if(op(t)&&n.trim().length===0){Y.error(e(`settings.magicPrompts.page.toast.visiblePromptRequired`));return}u(e=>({...e,[t]:!0}));try{let r=n===st(t)?await gt(t):await Ze(t,n);o(r.overrides),Y.success(e(`settings.magicPrompts.page.toast.saved`))}catch(t){let n=t instanceof Error?t.message:String(t);Y.error(e(`settings.magicPrompts.page.toast.saveFailed`),{description:n})}finally{u(e=>({...e,[t]:!1}))}},[_,e]),b=Q.useCallback(async t=>{f(e=>({...e,[t]:!0}));try{let n=await gt(t);o(n.overrides),c(e=>({...e,[t]:st(t)})),Y.success(e(`settings.magicPrompts.page.toast.resetSuccess`))}catch(t){let n=t instanceof Error?t.message:String(t);Y.error(e(`settings.magicPrompts.page.toast.resetFailed`),{description:n})}finally{f(e=>({...e,[t]:!1}))}},[e]),x=Q.useCallback(async()=>{m(!0);try{let t=await Et();o(t.overrides),c({}),Y.success(e(`settings.magicPrompts.page.toast.resetAllSuccess`))}catch(t){let n=t instanceof Error?t.message:String(t);Y.error(e(`settings.magicPrompts.page.toast.resetAllFailed`),{description:n})}finally{m(!1)}},[e]);return r?(0,$.jsxs)(`div`,{className:`py-6 px-6 flex items-center gap-2 text-muted-foreground`,children:[(0,$.jsx)(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full bg-current animate-busy-pulse`,"aria-label":e(`settings.magicPrompts.page.loading.aria`)}),(0,$.jsx)(`span`,{className:`typography-ui`,children:e(`settings.magicPrompts.page.loading.text`)})]}):(0,$.jsx)(`div`,{className:`h-full overflow-auto`,children:(0,$.jsxs)(`div`,{className:`oc-settings-page-content mx-auto w-full max-w-4xl px-6 py-6`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,$.jsx)(`div`,{className:`space-y-1`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`h2`,{className:`typography-ui-header font-semibold text-foreground`,children:t(h.titleKey)}),(0,$.jsxs)(hn,{children:[(0,$.jsx)(pn,{asChild:!0,children:(0,$.jsx)(X,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(mn,{sideOffset:8,className:`max-w-xs`,children:t(h.descriptionKey)})]})]})}),(0,$.jsx)(J,{"data-settings-item":`magic-prompts.reset-overrides`,variant:`outline`,size:`sm`,onClick:()=>{x()},disabled:p||Object.keys(a).length===0,children:e(p?`settings.magicPrompts.page.actions.resetting`:`settings.magicPrompts.page.actions.resetAllOverrides`)})]}),h.blocks.map(n=>{let r=wt(n.id),i=g(n.id),o=_(n.id),s=ap(a,n.id),c=o!==i,u=op(n.id)&&o.trim().length===0,f=l[n.id]===!0,p=d[n.id]===!0;return(0,$.jsx)(vi,{label:(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(`span`,{children:t(n.titleKey)}),(0,$.jsxs)(hn,{children:[(0,$.jsx)(pn,{asChild:!0,children:(0,$.jsx)(X,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(mn,{sideOffset:8,className:`max-w-xs`,children:r.description})]})]}),cardClassName:`p-3`,children:(0,$.jsxs)(`div`,{"data-settings-item":op(n.id)?`magic-prompts.visible-prompt`:`magic-prompts.instructions`,className:`space-y-3`,children:[r.placeholders&&r.placeholders.length>0&&(0,$.jsxs)(`div`,{className:`typography-micro text-muted-foreground`,children:[e(`settings.magicPrompts.page.placeholdersLabel`),` `,r.placeholders.map(e=>`{{${e.key}}}`).join(`, `)]}),(0,$.jsx)(Cr,{embedded:!0,value:o,onChange:e=>v(n.id,e.target.value),className:`min-h-[220px] font-mono text-sm`}),u&&(0,$.jsx)(`div`,{className:`typography-micro text-[var(--status-error)]`,children:e(`settings.magicPrompts.page.validation.visiblePromptRequired`)}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:e(c?`settings.magicPrompts.page.status.unsavedChanges`:s?`settings.magicPrompts.page.status.usingSavedOverride`:`settings.magicPrompts.page.status.usingBuiltinDefault`)}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(J,{variant:`outline`,size:`sm`,onClick:()=>{b(n.id)},disabled:!s||f||p,children:e(p?`settings.magicPrompts.page.actions.resetting`:`settings.magicPrompts.page.actions.resetToDefault`)}),(0,$.jsx)(J,{size:`sm`,onClick:()=>{y(n.id)},disabled:!c||f||p||u,children:e(f?`settings.common.actions.saving`:`settings.magicPrompts.page.actions.save`)})]})]})]})},n.id)})]})})},cp=e=>{let t=(0,Ii.c)(71),{onItemSelect:n}=e,{t:r}=Me(),[i,a]=Q.useState(null),[o,s]=Q.useState(null),[c,l]=Q.useState(null),{selectedSnippetName:u,snippets:d,setSelectedSnippet:f,setSnippetDraft:p,deleteSnippet:m,loadSnippets:h}=cn(le(lp)),g,_;t[0]===h?(g=t[1],_=t[2]):(g=()=>{h()},_=[h],t[0]=h,t[1]=g,t[2]=_),Q.useEffect(g,_);let v;t[3]!==n||t[4]!==f||t[5]!==p||t[6]!==d?(v=async()=>{let e=new Set(d.map(up)),t=`new-snippet`,r=1;for(;e.has(t);)t=`new-snippet-${r++}`;p({name:t,scope:`global`}),f(t),n?.()},t[3]=n,t[4]=f,t[5]=p,t[6]=d,t[7]=v):v=t[7];let y=v,b;t[8]!==i||t[9]!==m||t[10]!==r?(b=async()=>{i&&(await m(i.name)?(Y.success(r(`settings.snippets.sidebar.toast.deleted`)),a(null)):Y.error(r(`settings.snippets.sidebar.toast.deleteFailed`)))},t[8]=i,t[9]=m,t[10]=r,t[11]=b):b=t[11];let x=b,S;t[12]===d?S=t[13]:(S=[...d].sort(dp),t[12]=d,t[13]=S);let C=S,w;t[14]===r?w=t[15]:(w=r(`settings.snippets.sidebar.title`),t[14]=r,t[15]=w);let T;t[16]===w?T=t[17]:(T=(0,$.jsx)(`span`,{children:w}),t[16]=w,t[17]=T);let E;t[18]===r?E=t[19]:(E=r(`settings.snippets.sidebar.actions.create`),t[18]=r,t[19]=E);let D;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,$.jsx)(X,{name:`add`,className:`h-4 w-4`}),t[20]=D):D=t[20];let O;t[21]!==y||t[22]!==E?(O=(0,$.jsx)(J,{"data-settings-item":`snippets.create`,size:`icon`,variant:`ghost`,onClick:y,"aria-label":E,children:D}),t[21]=y,t[22]=E,t[23]=O):O=t[23];let k;t[24]!==O||t[25]!==T?(k=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[T,O]}),t[24]=O,t[25]=T,t[26]=k):k=t[26];let A=k,j;t[27]!==n||t[28]!==o||t[29]!==c||t[30]!==u||t[31]!==f||t[32]!==A||t[33]!==C||t[34]!==r?(j=C.length>0?(0,$.jsx)(vi,{label:A,children:C.map(e=>(0,$.jsxs)(ki,{open:c===e.name,onOpenChange:t=>l(t?e.name:null),children:[(0,$.jsxs)(Ei,{render:(0,$.jsx)(`div`,{className:q(`oc-settings-group-row group relative flex items-center transition-colors duration-150 select-none`,u===e.name?`bg-interactive-selection`:`hover:bg-interactive-hover`),onContextMenu:t=>{t.preventDefault(),l(e.name)}}),children:[(0,$.jsxs)(`button`,{onClick:()=>{f(e.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:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsxs)(`span`,{className:`typography-ui-label font-normal truncate text-foreground`,children:[`#`,e.name]}),(0,$.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:r(`snippets.source.${e.source}`)})]}),(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground/60 truncate leading-tight`,children:e.description||e.content.replace(/\s+/g,` `).substring(0,80)})]}),(0,$.jsxs)(cr,{open:o===e.name,onOpenChange:t=>{t&&l(null),s(t?e.name:null)},children:[(0,$.jsx)(mr,{asChild:!0,children:(0,$.jsx)(J,{size:`sm`,variant:`ghost`,className:`h-6 w-6 px-0 flex-shrink-0 -mr-1 opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100`,"aria-label":r(`settings.snippets.sidebar.actions.more`,{name:e.name}),children:(0,$.jsx)(X,{name:`more-2`,className:`h-3.5 w-3.5`})})}),(0,$.jsx)(Qn,{align:`end`,className:`w-fit min-w-20`,children:(0,$.jsxs)(Wn,{onClick:t=>{t.stopPropagation(),a(e)},className:`text-destructive focus:text-destructive`,children:[(0,$.jsx)(X,{name:`delete-bin`,className:`h-4 w-4 mr-px`}),r(`settings.common.actions.delete`)]})})]})]}),(0,$.jsx)(Di,{className:`w-fit min-w-20`,children:(0,$.jsxs)(Oi,{onClick:t=>{t.stopPropagation(),a(e)},className:`text-destructive focus:text-destructive`,children:[(0,$.jsx)(X,{name:`delete-bin`,className:`h-4 w-4 mr-px`}),r(`settings.common.actions.delete`)]})})]},`${e.source}:${e.filePath}`))}):(0,$.jsx)(vi,{label:A,cardClassName:`hidden`,children:(0,$.jsx)(`span`,{})}),t[27]=n,t[28]=o,t[29]=c,t[30]=u,t[31]=f,t[32]=A,t[33]=C,t[34]=r,t[35]=j):j=t[35];let M=i!==null,N;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(N=e=>{e||a(null)},t[36]=N):N=t[36];let P;t[37]===r?P=t[38]:(P=r(`settings.snippets.sidebar.dialog.deleteTitle`),t[37]=r,t[38]=P);let F;t[39]===P?F=t[40]:(F=(0,$.jsx)(Xt,{children:P}),t[39]=P,t[40]=F);let I=i?.name??``,L;t[41]!==r||t[42]!==I?(L=r(`settings.snippets.sidebar.dialog.deleteDescription`,{name:I}),t[41]=r,t[42]=I,t[43]=L):L=t[43];let R;t[44]===L?R=t[45]:(R=(0,$.jsx)(Zt,{children:L}),t[44]=L,t[45]=R);let z;t[46]!==F||t[47]!==R?(z=(0,$.jsxs)(qt,{children:[F,R]}),t[46]=F,t[47]=R,t[48]=z):z=t[48];let B;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(B=()=>a(null),t[49]=B):B=t[49];let V;t[50]===r?V=t[51]:(V=r(`settings.common.actions.cancel`),t[50]=r,t[51]=V);let H;t[52]===V?H=t[53]:(H=(0,$.jsx)(J,{size:`sm`,variant:`ghost`,onClick:B,children:V}),t[52]=V,t[53]=H);let U;t[54]===r?U=t[55]:(U=r(`settings.common.actions.delete`),t[54]=r,t[55]=U);let W;t[56]!==x||t[57]!==U?(W=(0,$.jsx)(J,{size:`sm`,onClick:x,children:U}),t[56]=x,t[57]=U,t[58]=W):W=t[58];let ee;t[59]!==H||t[60]!==W?(ee=(0,$.jsxs)(Jt,{children:[H,W]}),t[59]=H,t[60]=W,t[61]=ee):ee=t[61];let G;t[62]!==z||t[63]!==ee?(G=(0,$.jsxs)(Yt,{className:`max-w-md`,children:[z,ee]}),t[62]=z,t[63]=ee,t[64]=G):G=t[64];let te;t[65]!==M||t[66]!==G?(te=(0,$.jsx)(Qt,{open:M,onOpenChange:N,children:G}),t[65]=M,t[66]=G,t[67]=te):te=t[67];let ne;return t[68]!==j||t[69]!==te?(ne=(0,$.jsxs)(`div`,{className:`oc-settings-page-content h-full overflow-y-auto bg-background p-3`,children:[j,te]}),t[68]=j,t[69]=te,t[70]=ne):ne=t[70],ne};function lp(e){return{selectedSnippetName:e.selectedSnippetName,snippets:e.snippets,setSelectedSnippet:e.setSelectedSnippet,setSnippetDraft:e.setSnippetDraft,deleteSnippet:e.deleteSnippet,loadSnippets:e.loadSnippets}}function up(e){return e.name}function dp(e,t){return e.name.localeCompare(t.name)}var fp=()=>{let{t:e}=Me(),{selectedSnippetName:t,snippets:n,snippetDraft:r,setSnippetDraft:i,updateSnippet:a,createSnippet:o}=cn(le(e=>({selectedSnippetName:e.selectedSnippetName,snippets:e.snippets,snippetDraft:e.snippetDraft,setSnippetDraft:e.setSnippetDraft,updateSnippet:e.updateSnippet,createSnippet:e.createSnippet}))),s=Q.useMemo(()=>t?n.find(e=>e.name===t||e.aliases.includes(t))??null:null,[t,n]),c=!!(r&&r.name===t&&!s),[l,u]=Q.useState(``),[d,f]=Q.useState(`global`),[p,m]=Q.useState(``),[h,g]=Q.useState(``),[_,v]=Q.useState(``),[y,b]=Q.useState(!1),x=Q.useRef(null);Q.useEffect(()=>{if(c&&r){let e={draftName:r.name||``,draftScope:r.scope||`global`,description:r.description||``,aliases:(r.aliases||[]).join(`, `),content:r.content||``};u(e.draftName),f(e.draftScope),m(e.description),g(e.aliases),v(e.content),x.current=e}else if(s){let e={draftName:``,draftScope:`global`,description:s.description??``,aliases:s.aliases.join(`, `),content:s.content};m(e.description),g(e.aliases),v(e.content),x.current=e}},[s,c,t,r]);let S=Q.useMemo(()=>{let e=x.current;return e?c&&l!==e.draftName||c&&d!==e.draftScope?!0:p!==e.description||h!==e.aliases||_!==e.content:!1},[h,_,p,l,d,c]);return t?(0,$.jsx)(Sr,{outerClassName:`h-full`,className:`w-full`,children:(0,$.jsxs)(`div`,{className:`oc-settings-page-content mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`h2`,{className:`typography-ui-header font-semibold text-foreground truncate`,children:c?e(`settings.snippets.page.title.new`):`#${t}`}),s?(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground truncate`,children:s.filePath}):null]}),(0,$.jsx)(vi,{cardClassName:`p-3`,children:(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{children:[c?(0,$.jsxs)(`div`,{className:`mb-3 flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:`#`}),(0,$.jsx)(fn,{value:l,onChange:e=>u(e.target.value),placeholder:e(`settings.snippets.page.field.namePlaceholder`),className:`h-7 w-44 px-2`}),(0,$.jsxs)(ln,{value:d,onValueChange:e=>f(e),children:[(0,$.jsx)(rn,{className:`w-fit min-w-[100px]`,children:(0,$.jsx)(dn,{})}),(0,$.jsxs)(an,{align:`end`,children:[(0,$.jsx)(tn,{value:`global`,children:e(`settings.common.scope.global`)}),(0,$.jsx)(tn,{value:`project`,children:e(`settings.common.scope.project`)})]})]})]}):null,(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e(`settings.common.field.description`)}),(0,$.jsx)(fn,{value:p,onChange:e=>m(e.target.value),placeholder:e(`settings.snippets.page.field.descriptionPlaceholder`),className:`mt-1.5 h-7 w-full max-w-sm px-2`})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e(`settings.snippets.page.field.aliases`)}),(0,$.jsx)(fn,{value:h,onChange:e=>g(e.target.value),placeholder:e(`settings.snippets.page.field.aliasesPlaceholder`),className:`mt-1.5 h-7 w-full max-w-sm px-2`})]})]})}),(0,$.jsx)(`div`,{"data-settings-item":`snippets.content`,children:(0,$.jsx)(vi,{label:e(`settings.snippets.page.field.content`),description:e(`settings.snippets.page.hint`),cardClassName:`p-3`,children:(0,$.jsx)(Cr,{embedded:!0,value:_,onChange:e=>v(e.target.value),placeholder:e(`settings.snippets.page.field.contentPlaceholder`),rows:12,className:`w-full font-mono typography-meta min-h-[160px] max-h-[60vh] bg-transparent`})})}),(0,$.jsx)(`div`,{children:(0,$.jsx)(J,{onClick:async()=>{let n=c?l.trim().replace(/\s+/g,`-`):t?.trim();if(!n){Y.error(e(`settings.snippets.page.toast.nameRequired`));return}if(!_.trim()){Y.error(e(`settings.snippets.page.toast.contentRequired`));return}let r=h.split(`,`).map(e=>e.trim()).filter(Boolean);b(!0);try{if(!(c?await o(n,_,{aliases:r,description:p,scope:d}):await a(n,{content:_,aliases:r,description:p}))){Y.error(e(`settings.snippets.page.toast.saveFailed`));return}Y.success(e(`settings.snippets.page.toast.saved`)),c&&i(null)}finally{b(!1)}},disabled:y||!S,size:`xs`,className:`!font-normal`,children:e(y?`settings.common.actions.saving`:`settings.common.actions.saveChanges`)})})]})}):(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,$.jsxs)(`div`,{className:`text-center text-muted-foreground`,children:[(0,$.jsx)(X,{name:`file-text`,className:`mx-auto mb-3 h-12 w-12 opacity-50`}),(0,$.jsx)(`p`,{className:`typography-body`,children:e(`settings.snippets.page.empty.title`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 opacity-75`,children:e(`settings.snippets.page.empty.description`)})]})})},pp=()=>{let{t:e}=Me(),t=Mt(e=>e.settingsGitmojiEnabled),n=Mt(e=>e.setSettingsGitmojiEnabled),r=g(),i=K(e=>e.gitChangesViewMode),a=K(e=>e.setGitChangesViewMode),[o,s]=Q.useState(!0),c=Q.useMemo(()=>[{id:`flat`,label:e(`settings.openchamber.git.option.flatList`)},{id:`tree`,label:e(`settings.openchamber.git.option.treeView`)}],[e]);Q.useEffect(()=>{(async()=>{try{let e=null;if(!e){let t=L()?.settings;if(t)try{let n=(await t.load())?.settings;n&&(e={gitmojiEnabled:typeof n.gitmojiEnabled==`boolean`?n.gitmojiEnabled:void 0,gitChangesViewMode:n.gitChangesViewMode===`flat`||n.gitChangesViewMode===`tree`?n.gitChangesViewMode:void 0})}catch{}}if(!e){let t=await l(`/api/config/settings`,{method:`GET`,headers:{Accept:`application/json`}});t.ok&&(e=await t.json())}e&&(typeof e.gitmojiEnabled==`boolean`&&n(e.gitmojiEnabled),(e.gitChangesViewMode===`flat`||e.gitChangesViewMode===`tree`)&&a(e.gitChangesViewMode))}catch(e){console.warn(`Failed to load git settings:`,e)}finally{s(!1)}})()},[a,n]);let u=Q.useCallback(async e=>{n(e);try{await M({gitmojiEnabled:e})}catch(e){console.warn(`Failed to save gitmoji setting:`,e)}},[n]),d=Q.useCallback(e=>{e!==i&&(a(e),M({gitChangesViewMode:e}))},[i,a]);return o?null:(0,$.jsxs)(vi,{label:e(`settings.openchamber.git.title`),children:[(0,$.jsx)(Nr,{itemId:`git.changes-view`,label:e(`settings.openchamber.git.changesViewTitle`),controlClassName:`items-end`,children:(0,$.jsx)(`div`,{role:`radiogroup`,"aria-label":e(`settings.openchamber.git.changesViewAria`),className:`mt-0.5 space-y-0`,children:c.map(t=>{let n=i===t.id;return(0,$.jsxs)(`div`,{role:`button`,tabIndex:0,"aria-pressed":n,onClick:()=>{d(t.id)},onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),d(t.id))},className:`flex w-full items-center gap-2 py-0 text-left`,children:[(0,$.jsx)(Ks,{checked:n,onChange:()=>{d(t.id)},ariaLabel:e(`settings.openchamber.git.optionAria`,{option:t.label})}),(0,$.jsx)(`span`,{className:n?`typography-ui-label font-normal text-foreground`:`typography-ui-label font-normal text-foreground/50`,children:t.label})]},t.id)})})}),(0,$.jsxs)(`div`,{"data-settings-item":`git.gitmoji`,className:`oc-settings-group-row group flex cursor-pointer items-center gap-2`,role:`button`,tabIndex:0,"aria-pressed":t,onClick:()=>{u(!t)},onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),u(!t))},children:[(0,$.jsx)(sn,{checked:t,onChange:e=>{u(e)},ariaLabel:e(`settings.openchamber.git.enableGitmojiAria`)}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e(`settings.openchamber.git.enableGitmoji`)})]}),(0,$.jsxs)(`div`,{"data-settings-item":`git.gitignored-files`,className:`oc-settings-group-row group flex cursor-pointer items-center gap-2`,role:`button`,tabIndex:0,"aria-pressed":r,onClick:()=>p(!r),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),p(!r))},children:[(0,$.jsx)(sn,{checked:r,onChange:p,ariaLabel:e(`settings.openchamber.git.showGitignoredAria`)}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e(`settings.openchamber.git.showGitignored`)})]})]})},mp=({itemId:e})=>{let{t}=Me(),{isMobile:n}=yr(),r=L()?.github,i=En(),a=i.data??null,o=i.isLoading&&!i.data,s=i.isFetched,c=oi(e=>e.refreshStatus),u=oi(e=>e.setStatus),d=Q.useCallback(async e=>{await kr(e)},[]),[f,p]=Q.useState(!1),[m,h]=Q.useState(null),[g,_]=Q.useState(null),v=Q.useRef(null),y=Q.useRef(0),b=Q.useCallback(()=>{v.current!=null&&(window.clearTimeout(v.current),v.current=null),_(null)},[]);Q.useEffect(()=>((async()=>{try{s||await c(r)}catch(e){console.warn(`Failed to load GitHub auth status:`,e)}})(),()=>{b()}),[s,c,r,b]);let x=Q.useCallback(async()=>{p(!0);try{let e=r?await r.authStart():await(async()=>{let e=await l(`/api/github/auth/start`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({})}),t=await e.json().catch(()=>null);if(!e.ok||!t||!(`deviceCode`in t))throw Error(t?.error||e.statusText);return t})();h(e),y.current=Date.now(),_(Math.max(1,e.interval)*1e3);let t=e.verificationUriComplete||e.verificationUri;d(t)}catch(e){console.error(`Failed to start GitHub connect:`,e),Y.error(t(`settings.github.page.toast.startConnectFailed`))}finally{p(!1)}},[d,r,t]),S=Q.useCallback(async e=>{if(r)return r.authComplete(e);let t=await l(`/api/github/auth/complete`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({deviceCode:e})}),n=await t.json().catch(()=>null);if(!t.ok||!n)throw Error(n?.error||t.statusText);return n},[r]);Q.useEffect(()=>{if(!m?.deviceCode||!g||v.current!=null)return;let e=!1,n=y.current+m.expiresIn*1e3,i=async()=>{if(Date.now()>=n){Y.error(t(`settings.github.page.toast.authorizationFailed`)),h(null),b();return}try{let n=await S(m.deviceCode);if(e)return;if(n.connected){Y.success(t(`settings.github.page.toast.connected`)),h(null),b(),await c(r,{force:!0});return}if(n.status===`slow_down`){_(e=>e?e+5e3:5e3);return}if(n.status===`expired_token`||n.status===`access_denied`){Y.error(n.error||t(`settings.github.page.toast.authorizationFailed`)),h(null),b();return}}catch(t){if(e)return;console.warn(`GitHub polling failed:`,t)}v.current=window.setTimeout(()=>void i(),g)};return v.current=window.setTimeout(()=>void i(),g),()=>{e=!0,v.current!=null&&(window.clearTimeout(v.current),v.current=null)}},[m,g,S,c,r,b,t]);let C=Q.useCallback(async e=>{p(!0);try{if(r)await r.authSetGhCliDisabled(e);else{let t=await l(`/api/github/auth/gh-cli`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({disabled:e})}),n=await t.json().catch(()=>null);if(!t.ok)throw Error(n?.error||t.statusText)}Y.success(t(e?`settings.github.page.toast.ghCliDisabled`:`settings.github.page.toast.ghCliEnabled`)),await c(r,{force:!0})}catch(e){console.error(`Failed to update gh CLI setting:`,e),Y.error(t(`settings.github.page.toast.ghCliUpdateFailed`))}finally{p(!1)}},[c,r,t]),w=Q.useCallback(async()=>{p(!0);try{if(b(),h(null),r)await r.authDisconnect();else{let e=await l(`/api/github/auth`,{method:`DELETE`,headers:{Accept:`application/json`}});if(!e.ok)throw Error(e.statusText)}Y.success(t(`settings.github.page.toast.disconnected`)),await c(r,{force:!0})}catch(e){console.error(`Failed to disconnect GitHub:`,e),Y.error(t(`settings.github.page.toast.disconnectFailed`))}finally{p(!1)}},[c,r,b,t]),T=Q.useCallback(async e=>{if(e){p(!0);try{let n=r?await r.authActivate(e):await(async()=>{let t=await l(`/api/github/auth/activate`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({accountId:e})}),n=await t.json().catch(()=>null);if(!t.ok||!n)throw Error(n?.error||t.statusText);return n})();u(n),Y.success(t(`settings.github.page.toast.accountSwitched`))}catch(e){console.error(`Failed to switch GitHub account:`,e),Y.error(t(`settings.github.page.toast.accountSwitchFailed`))}finally{p(!1)}}},[r,u,t]);if(o)return null;if(i.isError&&!i.data)return(0,$.jsx)(`div`,{className:`oc-settings-group-description text-[var(--status-error)]`,children:i.error.message});let E=!!a?.connected,D=a?.user,O=(a?.accounts??[]).filter(e=>!e.current),k=a?.ghCli??null,A=k?.active?t(`settings.github.page.accountSource.cli`):t(`settings.github.page.accountSource.oauth`);return(0,$.jsxs)(`div`,{className:`oc-settings-section-stack`,children:[(0,$.jsxs)(vi,{itemId:e,label:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{children:t(`settings.github.page.oauth.title`)}),(0,$.jsxs)(hn,{children:[(0,$.jsx)(pn,{asChild:!0,children:(0,$.jsx)(X,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(mn,{sideOffset:8,className:`max-w-xs`,children:t(`settings.github.page.tooltip.connectAccount`)})]})]}),children:[(0,$.jsxs)(`div`,{className:`overflow-hidden flex flex-col`,children:[E?(0,$.jsxs)(`div`,{className:q(`px-4 py-3`,n?`flex flex-col gap-3`:`flex items-center justify-between gap-4`),children:[(0,$.jsxs)(`div`,{className:q(`flex min-w-0 items-center gap-4`,n?`w-full`:void 0),children:[D?.avatarUrl?(0,$.jsx)(`img`,{src:D.avatarUrl,alt:D.login?t(`settings.github.page.avatarAlt.withLogin`,{login:D.login}):t(`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`}):(0,$.jsx)(`div`,{className:`h-10 w-10 shrink-0 rounded-full border border-[var(--interactive-border)] bg-[var(--surface-muted)]`}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:D?.name?.trim()||D?.login||`GitHub`}),(0,$.jsxs)(`div`,{className:q(`flex items-center gap-2 typography-meta text-muted-foreground mt-0.5`,n?`flex-wrap`:`truncate`),children:[(0,$.jsx)(X,{name:`github-fill`,className:`h-3.5 w-3.5 shrink-0`}),(0,$.jsx)(`span`,{className:`font-mono`,children:D?.login||t(`settings.github.page.label.unknownUser`)}),D?.email&&(0,$.jsx)(`span`,{className:`opacity-50`,children:`•`}),D?.email&&(0,$.jsx)(`span`,{children:D.email}),(0,$.jsx)(`span`,{className:`opacity-50`,children:`•`}),(0,$.jsx)(`span`,{children:A})]}),a?.scope&&(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground/70 mt-0.5`,children:t(`settings.github.page.label.scopes`,{value:a.scope})}),k?.active&&(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground/70 mt-0.5`,children:t(`settings.github.page.ghCli.activeDescription`)})]})]}),k?.active?(0,$.jsx)(J,{size:`sm`,variant:`outline`,onClick:()=>C(!0),disabled:f,className:q(n?`w-full`:void 0),children:t(`settings.github.page.ghCli.actions.disable`)}):(0,$.jsx)(J,{size:`sm`,variant:`outline`,onClick:w,disabled:f,className:q(`text-[var(--status-error)] hover:text-[var(--status-error)]`,n?`w-full`:void 0),children:t(`settings.github.page.actions.disconnect`)})]}):(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-4 px-4 py-4`,children:[(0,$.jsx)(`div`,{className:`flex min-w-0 flex-col`,children:(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:t(`settings.github.page.status.notConnected`)})}),(0,$.jsx)(J,{size:`sm`,variant:`default`,onClick:x,disabled:f,children:t(`settings.github.page.actions.connect`)})]}),O.length>0&&(0,$.jsxs)(`div`,{className:`mt-2 border-t border-[var(--surface-subtle)] pt-2 px-2 pb-1`,children:[(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground mb-2 px-1`,children:t(`settings.github.page.label.otherAccounts`)}),(0,$.jsx)(`div`,{className:`space-y-1`,children:O.map(e=>{let n=e.user,r=e.source===`gh-cli`?t(`settings.github.page.accountSource.cli`):t(`settings.github.page.accountSource.oauth`);return(0,$.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:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[n?.avatarUrl?(0,$.jsx)(`img`,{src:n.avatarUrl,alt:n.login?t(`settings.github.page.avatarAlt.withLogin`,{login:n.login}):t(`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`}):(0,$.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:(0,$.jsx)(X,{name:`github-fill`,className:`h-3 w-3 text-muted-foreground`})}),(0,$.jsxs)(`div`,{className:`min-w-0 flex flex-col`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground truncate`,children:n?.name?.trim()||n?.login||`GitHub`}),n?.login&&(0,$.jsxs)(`span`,{className:`typography-micro text-muted-foreground truncate`,children:[(0,$.jsx)(`span`,{className:`font-mono`,children:n.login}),(0,$.jsx)(`span`,{className:`mx-1 opacity-50`,children:`·`}),(0,$.jsx)(`span`,{children:r})]})]})]}),(0,$.jsx)(J,{size:`sm`,variant:`ghost`,onClick:()=>T(e.id),disabled:f,children:t(`settings.github.page.actions.switchTo`)})]},e.id)})})]})]}),E&&(0,$.jsx)(`div`,{className:`mt-2 px-2 pb-2`,children:(0,$.jsx)(J,{size:`sm`,variant:`outline`,onClick:x,disabled:f,className:q(n?`w-full`:void 0),children:t(`settings.github.page.actions.addAccount`)})})]}),m&&(0,$.jsxs)(`div`,{className:`mt-4 rounded-lg bg-[var(--surface-elevated)]/70 p-4 border border-[var(--interactive-border)]`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`h4`,{className:`typography-ui-label text-foreground`,children:t(`settings.github.page.flow.title`)}),(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.github.page.flow.description`)})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 mt-4`,children:[(0,$.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:m.userCode}),(0,$.jsx)(J,{size:`sm`,asChild:!0,children:(0,$.jsx)(`a`,{href:m.verificationUriComplete||m.verificationUri,target:`_blank`,rel:`noopener noreferrer`,children:t(`settings.github.page.actions.openGithub`)})})]}),(0,$.jsxs)(`div`,{className:`mt-4 flex items-center justify-between`,children:[(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground animate-pulse`,children:t(`settings.github.page.flow.waiting`)}),(0,$.jsx)(J,{size:`sm`,variant:`ghost`,disabled:f,onClick:()=>{b(),h(null)},children:t(`settings.common.actions.cancel`)})]})]}),k?.available&&!k?.active&&(!k.user||k.disabled)&&(0,$.jsx)(vi,{label:t(`settings.github.page.ghCli.title`),children:(0,$.jsx)(`div`,{className:`overflow-hidden`,children:(0,$.jsxs)(`div`,{className:q(`px-4 py-3`,n?`flex flex-col gap-3`:`flex items-center justify-between gap-4`),children:[(0,$.jsxs)(`div`,{className:q(`flex min-w-0 items-center gap-4`,n?`w-full`:void 0),children:[k.user?.avatarUrl?(0,$.jsx)(`img`,{src:k.user.avatarUrl,alt:k.user.login?t(`settings.github.page.avatarAlt.withLogin`,{login:k.user.login}):t(`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`}):(0,$.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:(0,$.jsx)(X,{name:`github-fill`,className:`h-4 w-4 text-muted-foreground`})}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[!k.disabled&&k.user&&(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground truncate`,children:k.user.name?.trim()||k.user.login||`GitHub`}),!k.disabled&&k.user?.login&&(0,$.jsxs)(`div`,{className:q(`flex items-center gap-2 typography-meta text-muted-foreground mt-0.5`,n?`flex-wrap`:`truncate`),children:[(0,$.jsx)(X,{name:`github-fill`,className:`h-3.5 w-3.5 shrink-0`}),(0,$.jsx)(`span`,{className:`font-mono`,children:k.user.login}),k.user.email&&(0,$.jsx)(`span`,{className:`opacity-50`,children:`•`}),k.user.email&&(0,$.jsx)(`span`,{children:k.user.email})]}),(0,$.jsx)(`div`,{className:q(`typography-meta text-muted-foreground`,k.disabled?`opacity-60`:void 0),children:k.disabled?t(`settings.github.page.ghCli.disabledDescription`):t(`settings.github.page.ghCli.fallbackDescription`)})]})]}),(0,$.jsx)(J,{size:`sm`,variant:`outline`,onClick:()=>C(!k.disabled),disabled:f,className:q(n?`w-full`:void 0),children:k.disabled?t(`settings.github.page.ghCli.actions.enable`):t(`settings.github.page.ghCli.actions.disable`)})]})})})]})},hp=[{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)`}],gp=[{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`}],_p=({open:e,onOpenChange:t,profileId:n,importData:r})=>{let{t:i}=Me(),a=Mr(e=>e.getProfileById),o=Mr(e=>e.createProfile),s=Mr(e=>e.updateProfile),c=Mr(e=>e.deleteProfile),l=Q.useMemo(()=>n&&n!==`new`&&!r?a(n):null,[n,a,r]),u=n===`new`||r!=null,d=n===`global`,[f,p]=Q.useState(``),[m,h]=Q.useState(``),[g,_]=Q.useState(``),[v,y]=Q.useState(`ssh`),[b,x]=Q.useState(``),[S,C]=Q.useState(!1),[w,T]=Q.useState(``),[E,D]=Q.useState(``),[O,k]=Q.useState(`keyword`),[A,j]=Q.useState(`branch`),[M,N]=Q.useState(!1),[P,F]=Q.useState(!1),[I,L]=Q.useState(!1);Q.useEffect(()=>{if(e){if(r){let e=r.host.split(`/`),t=e.length>=3?e[e.length-1]:r.host;p(t),h(r.username),_(``),y(`token`),x(``),C(!1),T(``),D(r.host),k(`string`),j(`code`)}else if(u)p(``),h(``),_(``),y(`ssh`),x(``),C(!1),T(``),D(``),k(`keyword`),j(`branch`);else if(l)p(l.name),h(l.userName),_(l.userEmail),y(l.authType||`ssh`),x(l.sshKey||``),C(l.signCommits===!0),T(l.signingKey||``),D(l.host||``),k(l.color||`keyword`),j(l.icon||`branch`);else if(d){let e=a(`global`);e&&(p(e.name),h(e.userName),_(e.userEmail),y(e.authType||`ssh`),x(e.sshKey||``),C(!1),T(``),D(e.host||``),k(e.color||`keyword`),j(e.icon||`branch`))}}},[e,n,l,u,r,d,a]);let R=async()=>{if(!m.trim()||!g.trim()){Y.error(i(`settings.gitIdentities.editor.toast.userNameEmailRequired`));return}if(v===`token`&&!E.trim()){Y.error(i(`settings.gitIdentities.editor.toast.hostRequiredForToken`));return}if(S&&!w.trim()){Y.error(i(`settings.gitIdentities.editor.toast.signingKeyRequired`));return}N(!0);try{let e={name:f.trim()||m.trim(),userName:m.trim(),userEmail:g.trim(),authType:v,sshKey:v===`ssh`&&b.trim()||null,signCommits:S,signingKey:w.trim()||null,host:v===`token`&&E.trim()||null,color:O,icon:A},r;if(u)r=await o(e);else if(n)r=await s(n,e);else return;r?(Y.success(i(u?`settings.gitIdentities.editor.toast.profileCreated`:`settings.gitIdentities.editor.toast.profileUpdated`)),t(!1)):Y.error(i(u?`settings.gitIdentities.editor.toast.createProfileFailed`:`settings.gitIdentities.editor.toast.updateProfileFailed`))}catch(e){console.error(`Error saving profile:`,e),Y.error(i(`settings.gitIdentities.editor.toast.saveUnexpectedError`))}finally{N(!1)}},z=async()=>{if(!(!n||u)){L(!0);try{await c(n)?(Y.success(i(`settings.gitIdentities.editor.toast.profileDeleted`)),F(!1),t(!1)):Y.error(i(`settings.gitIdentities.editor.toast.deleteProfileFailed`))}catch(e){console.error(`Error deleting profile:`,e),Y.error(i(`settings.gitIdentities.editor.toast.deleteUnexpectedError`))}finally{L(!1)}}},B=Q.useMemo(()=>hp.find(e=>e.key===O)?.cssVar||`var(--syntax-keyword)`,[O]),V=r?i(`settings.gitIdentities.editor.title.importCredential`):u?i(`settings.gitIdentities.editor.title.newIdentity`):d?i(`settings.gitIdentities.editor.title.globalIdentity`):l?.name||i(`settings.gitIdentities.editor.title.editIdentity`);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Qt,{open:e,onOpenChange:t,children:(0,$.jsxs)(Yt,{className:`max-w-lg max-h-[85vh] overflow-y-auto`,children:[(0,$.jsxs)(qt,{children:[(0,$.jsx)(Xt,{children:V}),(0,$.jsx)(Zt,{children:i(d?`settings.gitIdentities.editor.description.globalReadOnly`:u?`settings.gitIdentities.editor.description.newProfile`:`settings.gitIdentities.editor.description.editProfile`)})]}),(0,$.jsxs)(`div`,{className:`space-y-5 py-2`,children:[!d&&(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`label`,{className:`typography-ui-label text-foreground block mb-1.5`,children:i(`settings.gitIdentities.editor.field.profileName`)}),(0,$.jsx)(fn,{value:f,onChange:e=>p(e.target.value),placeholder:i(`settings.gitIdentities.editor.field.profileNamePlaceholder`),className:`h-8`})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:i(`settings.gitIdentities.editor.field.color`)}),(0,$.jsx)(`div`,{className:`flex gap-1.5`,children:hp.map(e=>(0,$.jsx)(`button`,{type:`button`,onClick:()=>k(e.key),className:q(`w-6 h-6 rounded-md border-2 transition-all cursor-pointer`,O===e.key?`border-foreground scale-110`:`border-transparent hover:border-border`),style:{backgroundColor:e.cssVar},title:e.label},e.key))})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:i(`settings.gitIdentities.editor.field.icon`)}),(0,$.jsx)(`div`,{className:`flex gap-1.5`,children:gp.map(e=>{let t=e.Icon;return(0,$.jsx)(`button`,{type:`button`,onClick:()=>j(e.key),className:q(`w-7 h-7 rounded-md border-2 transition-all flex items-center justify-center cursor-pointer`,A===e.key?`border-[var(--interactive-border)] bg-[var(--surface-muted)]`:`border-transparent hover:border-[var(--interactive-border)] hover:bg-[var(--surface-muted)]/50`),title:e.label,children:(0,$.jsx)(X,{name:t,className:`w-3.5 h-3.5`,style:{color:A===e.key?B:`var(--surface-muted-foreground)`}})},e.key)})})]})]}),!d&&(0,$.jsx)(`div`,{className:`border-t border-border/40`}),(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 mb-1.5`,children:[(0,$.jsx)(`label`,{className:`typography-ui-label text-foreground`,children:i(`settings.gitIdentities.editor.field.userName`)}),!d&&(0,$.jsx)(`span`,{className:`text-[var(--status-error)] text-xs`,children:`*`}),(0,$.jsxs)(hn,{children:[(0,$.jsx)(pn,{asChild:!0,children:(0,$.jsx)(X,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(mn,{sideOffset:8,className:`max-w-xs`,children:i(`settings.gitIdentities.editor.field.userNameTooltip`)})]})]}),(0,$.jsx)(fn,{value:m,onChange:e=>h(e.target.value),placeholder:i(`settings.gitIdentities.editor.field.userNamePlaceholder`),required:!d,readOnly:d,disabled:d,className:`h-8`})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 mb-1.5`,children:[(0,$.jsx)(`label`,{className:`typography-ui-label text-foreground`,children:i(`settings.gitIdentities.editor.field.emailAddress`)}),!d&&(0,$.jsx)(`span`,{className:`text-[var(--status-error)] text-xs`,children:`*`}),(0,$.jsxs)(hn,{children:[(0,$.jsx)(pn,{asChild:!0,children:(0,$.jsx)(X,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(mn,{sideOffset:8,className:`max-w-xs`,children:i(`settings.gitIdentities.editor.field.emailAddressTooltip`)})]})]}),(0,$.jsx)(fn,{type:`email`,value:g,onChange:e=>_(e.target.value),placeholder:i(`settings.gitIdentities.editor.field.emailAddressPlaceholder`),required:!d,readOnly:d,disabled:d,className:`h-8`})]})]}),!d&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`border-t border-border/40`}),(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:i(`settings.gitIdentities.editor.field.authMethod`)}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,$.jsxs)(J,{size:`sm`,type:`button`,variant:`chip`,"aria-pressed":v===`ssh`,onClick:()=>y(`ssh`),children:[(0,$.jsx)(X,{name:`lock-2`,className:`w-3.5 h-3.5 mr-1`}),` SSH`]}),(0,$.jsxs)(J,{size:`sm`,type:`button`,variant:`chip`,"aria-pressed":v===`token`,onClick:()=>y(`token`),children:[(0,$.jsx)(X,{name:`key`,className:`w-3.5 h-3.5 mr-1`}),` `,i(`settings.gitIdentities.editor.field.authToken`)]})]})]}),v===`ssh`&&(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 mb-1.5`,children:[(0,$.jsx)(`label`,{className:`typography-ui-label text-foreground`,children:i(`settings.gitIdentities.editor.field.sshKeyPath`)}),(0,$.jsxs)(hn,{children:[(0,$.jsx)(pn,{asChild:!0,children:(0,$.jsx)(X,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(mn,{sideOffset:8,className:`max-w-xs`,children:i(`settings.gitIdentities.editor.field.sshKeyPathTooltip`)})]})]}),(0,$.jsx)(fn,{value:b,onChange:e=>x(e.target.value),placeholder:i(`settings.gitIdentities.editor.field.sshKeyPathPlaceholder`),className:`h-8 font-mono text-xs`})]}),(0,$.jsxs)(`div`,{className:`border-t border-border/40 pt-3 space-y-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,$.jsx)(sn,{checked:S,onChange:C,ariaLabel:i(`settings.gitIdentities.editor.field.signCommits`)}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:i(`settings.gitIdentities.editor.field.signCommits`)}),(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground/70`,children:i(`settings.gitIdentities.editor.section.commitSigning`)})]})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`flex items-center gap-1.5 mb-1.5`,children:(0,$.jsx)(`label`,{className:`typography-ui-label text-foreground`,children:i(`settings.gitIdentities.editor.field.signingKey`)})}),(0,$.jsx)(fn,{value:w,onChange:e=>T(e.target.value),placeholder:i(`settings.gitIdentities.editor.field.signingKeyPlaceholder`),disabled:!S,className:`h-8 font-mono text-xs`})]})]}),v===`token`&&(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 mb-1.5`,children:[(0,$.jsx)(`label`,{className:`typography-ui-label text-foreground`,children:i(`settings.gitIdentities.editor.field.host`)}),(0,$.jsx)(`span`,{className:`text-[var(--status-error)] text-xs`,children:`*`}),(0,$.jsxs)(hn,{children:[(0,$.jsx)(pn,{asChild:!0,children:(0,$.jsx)(X,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(mn,{sideOffset:8,className:`max-w-xs`,children:i(`settings.gitIdentities.editor.field.hostTooltip`)})]})]}),(0,$.jsx)(fn,{value:E,onChange:e=>D(e.target.value),placeholder:i(`settings.gitIdentities.editor.field.hostPlaceholder`),required:!0,className:`h-8 font-mono text-xs`})]})]})]})]}),(0,$.jsxs)(Jt,{className:`gap-2`,children:[!d&&!u&&(0,$.jsxs)(J,{variant:`outline`,size:`sm`,onClick:()=>F(!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:[(0,$.jsx)(X,{name:`delete-bin`,className:`w-3.5 h-3.5 mr-1`}),` `,i(`settings.common.actions.delete`)]}),(0,$.jsx)(J,{variant:`ghost`,size:`sm`,onClick:()=>t(!1),className:`text-foreground hover:bg-interactive-hover hover:text-foreground`,children:i(d?`settings.gitIdentities.editor.actions.close`:`settings.common.actions.cancel`)}),!d&&(0,$.jsx)(J,{size:`sm`,onClick:R,disabled:M,children:i(M?`settings.common.actions.saving`:u?`settings.gitIdentities.editor.actions.create`:`settings.gitIdentities.editor.actions.save`)})]})]})}),(0,$.jsx)(Qt,{open:P,onOpenChange:e=>{I||F(e)},children:(0,$.jsxs)(Yt,{className:`max-w-md`,children:[(0,$.jsxs)(qt,{children:[(0,$.jsx)(Xt,{children:i(`settings.gitIdentities.page.deleteDialog.title`)}),(0,$.jsx)(Zt,{children:i(`settings.gitIdentities.page.deleteDialog.description`,{name:l?.name||f})})]}),(0,$.jsxs)(Jt,{children:[(0,$.jsx)(J,{variant:`ghost`,onClick:()=>F(!1),disabled:I,children:i(`settings.common.actions.cancel`)}),(0,$.jsx)(J,{size:`sm`,variant:`destructive`,onClick:()=>void z(),disabled:I,children:i(`settings.common.actions.delete`)})]})]})})]})},vp={branch:`git-branch`,briefcase:`briefcase`,house:`home`,graduation:`graduation-cap`,code:`code`,heart:`heart`},yp={keyword:`var(--syntax-keyword)`,error:`var(--status-error)`,string:`var(--syntax-string)`,function:`var(--syntax-function)`,type:`var(--syntax-type)`},bp=()=>{let e=(0,Ii.c)(116),{t}=Me(),{profiles:n,globalIdentity:r,defaultGitIdentityId:i,deleteProfile:a,loadProfiles:o,loadGlobalIdentity:s,loadDiscoveredCredentials:c,loadDefaultGitIdentityId:l,setDefaultGitIdentityId:u,getUnimportedCredentials:d}=Mr(le(Cp)),[f,p]=Q.useState(!1),[m,h]=Q.useState(null),[g,_]=Q.useState(null),[v,y]=Q.useState(null),[b,x]=Q.useState(!1),S,C;e[0]!==l||e[1]!==c||e[2]!==s||e[3]!==o?(S=()=>{o(),s(),c(),l()},C=[o,s,c,l],e[0]=l,e[1]=c,e[2]=s,e[3]=o,e[4]=S,e[5]=C):(S=e[4],C=e[5]),Q.useEffect(S,C);let w,T,E,D,O,k,A,j,M,N,P,F,I,L;if(e[6]!==i||e[7]!==v||e[8]!==a||e[9]!==d||e[10]!==r||e[11]!==n||e[12]!==u||e[13]!==t){let o=d(),s;e[28]===Symbol.for(`react.memo_cache_sentinel`)?(s=(e,t)=>{h(e),_(t??null),p(!0)},e[28]=s):s=e[28];let c=s,l;e[29]!==i||e[30]!==u||e[31]!==t?(l=async e=>{let n=i===e?null:e;if(!await u(n)){Y.error(t(`settings.gitIdentities.page.toast.updateDefaultFailed`));return}Y.success(t(n?`settings.gitIdentities.page.toast.defaultUpdated`:`settings.gitIdentities.page.toast.defaultUnset`))},e[29]=i,e[30]=u,e[31]=t,e[32]=l):l=e[32];let f=l,m;e[33]!==v||e[34]!==a||e[35]!==t?(m=async()=>{v&&(x(!0),await a(v.id)?(Y.success(t(`settings.gitIdentities.page.toast.profileDeleted`,{name:v.name})),y(null)):Y.error(t(`settings.gitIdentities.page.toast.deleteProfileFailed`)),x(!1))},e[33]=v,e[34]=a,e[35]=t,e[36]=m):m=e[36],E=m,T=Sr,O=`h-full`,k=`w-full bg-background`,L=`oc-settings-page-content mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8`,e[37]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,$.jsx)(mp,{itemId:`git.github-account`}),e[37]=D):D=e[37],w=vi,A=`git.identities`;let g;e[38]===t?g=e[39]:(g=t(`settings.gitIdentities.page.section.title`),e[38]=t,e[39]=g);let b;e[40]===g?b=e[41]:(b=(0,$.jsx)(`span`,{children:g}),e[40]=g,e[41]=b);let S,C;e[42]===Symbol.for(`react.memo_cache_sentinel`)?(S=()=>c(`new`),C=(0,$.jsx)(X,{name:`add`,className:`mr-1 size-3.5`}),e[42]=S,e[43]=C):(S=e[42],C=e[43]);let R;e[44]===t?R=e[45]:(R=t(`settings.common.badge.new`),e[44]=t,e[45]=R);let z;e[46]===R?z=e[47]:(z=(0,$.jsxs)(J,{size:`sm`,variant:`ghost`,onClick:S,children:[C,` `,R]}),e[46]=R,e[47]=z),e[48]!==b||e[49]!==z?(j=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[b,z]}),e[48]=b,e[49]=z,e[50]=j):j=e[50],M=`flex flex-col`,N=r&&(0,$.jsx)(xp,{profile:r,isDefault:i===`global`,onEdit:()=>c(`global`),onToggleDefault:()=>f(`global`),isReadOnly:!0,hasBorder:n.length>0||o.length>0}),P=n.map((e,t)=>(0,$.jsx)(xp,{profile:e,isDefault:i===e.id,onEdit:()=>c(e.id),onToggleDefault:()=>f(e.id),onDelete:()=>y(e),hasBorder:t<n.length-1||o.length>0},e.id)),F=!r&&n.length===0&&o.length===0&&(0,$.jsxs)(`div`,{className:`py-8 px-4 text-center text-muted-foreground`,children:[(0,$.jsx)(X,{name:`shield-keyhole`,className:`mx-auto mb-2 h-8 w-8 opacity-40`}),(0,$.jsx)(`p`,{className:`typography-ui-label`,children:t(`settings.gitIdentities.page.empty.title`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 opacity-75`,children:t(`settings.gitIdentities.page.empty.description`)})]}),I=o.length>0&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`px-4 py-2 border-t border-[var(--surface-subtle)]`,children:(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:t(`settings.gitIdentities.page.discoveredCredentials.title`)})}),o.map((e,t)=>(0,$.jsx)(Sp,{credential:e,onImport:()=>c(`new`,{host:e.host,username:e.username}),hasBorder:t<o.length-1},`${e.host}-${e.username}`))]}),e[6]=i,e[7]=v,e[8]=a,e[9]=d,e[10]=r,e[11]=n,e[12]=u,e[13]=t,e[14]=w,e[15]=T,e[16]=E,e[17]=D,e[18]=O,e[19]=k,e[20]=A,e[21]=j,e[22]=M,e[23]=N,e[24]=P,e[25]=F,e[26]=I,e[27]=L}else w=e[14],T=e[15],E=e[16],D=e[17],O=e[18],k=e[19],A=e[20],j=e[21],M=e[22],N=e[23],P=e[24],F=e[25],I=e[26],L=e[27];let R;e[51]!==w||e[52]!==A||e[53]!==j||e[54]!==M||e[55]!==N||e[56]!==P||e[57]!==F||e[58]!==I?(R=(0,$.jsxs)(w,{itemId:A,label:j,cardClassName:M,children:[N,P,F,I]}),e[51]=w,e[52]=A,e[53]=j,e[54]=M,e[55]=N,e[56]=P,e[57]=F,e[58]=I,e[59]=R):R=e[59];let z;e[60]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,$.jsx)(pp,{}),e[60]=z):z=e[60];let B;e[61]!==D||e[62]!==R||e[63]!==L?(B=(0,$.jsxs)(`div`,{className:L,children:[D,R,z]}),e[61]=D,e[62]=R,e[63]=L,e[64]=B):B=e[64];let V;e[65]!==T||e[66]!==O||e[67]!==k||e[68]!==B?(V=(0,$.jsx)(T,{outerClassName:O,className:k,children:B}),e[65]=T,e[66]=O,e[67]=k,e[68]=B,e[69]=V):V=e[69];let H;e[70]!==g||e[71]!==f||e[72]!==m?(H=(0,$.jsx)(_p,{open:f,onOpenChange:p,profileId:m,importData:g}),e[70]=g,e[71]=f,e[72]=m,e[73]=H):H=e[73];let U=v!==null,W;e[74]===b?W=e[75]:(W=e=>{b||e||y(null)},e[74]=b,e[75]=W);let ee;e[76]===t?ee=e[77]:(ee=t(`settings.gitIdentities.page.deleteDialog.title`),e[76]=t,e[77]=ee);let G;e[78]===ee?G=e[79]:(G=(0,$.jsx)(Xt,{children:ee}),e[78]=ee,e[79]=G);let te=v?.name??``,ne;e[80]!==t||e[81]!==te?(ne=t(`settings.gitIdentities.page.deleteDialog.description`,{name:te}),e[80]=t,e[81]=te,e[82]=ne):ne=e[82];let re;e[83]===ne?re=e[84]:(re=(0,$.jsx)(Zt,{children:ne}),e[83]=ne,e[84]=re);let ie;e[85]!==G||e[86]!==re?(ie=(0,$.jsxs)(qt,{children:[G,re]}),e[85]=G,e[86]=re,e[87]=ie):ie=e[87];let ae;e[88]===Symbol.for(`react.memo_cache_sentinel`)?(ae=()=>y(null),e[88]=ae):ae=e[88];let oe;e[89]===t?oe=e[90]:(oe=t(`settings.common.actions.cancel`),e[89]=t,e[90]=oe);let se;e[91]!==b||e[92]!==oe?(se=(0,$.jsx)(J,{variant:`ghost`,onClick:ae,disabled:b,children:oe}),e[91]=b,e[92]=oe,e[93]=se):se=e[93];let ce;e[94]===E?ce=e[95]:(ce=()=>void E(),e[94]=E,e[95]=ce);let ue;e[96]===t?ue=e[97]:(ue=t(`settings.common.actions.delete`),e[96]=t,e[97]=ue);let de;e[98]!==b||e[99]!==ce||e[100]!==ue?(de=(0,$.jsx)(J,{size:`sm`,variant:`destructive`,onClick:ce,disabled:b,children:ue}),e[98]=b,e[99]=ce,e[100]=ue,e[101]=de):de=e[101];let fe;e[102]!==se||e[103]!==de?(fe=(0,$.jsxs)(Jt,{children:[se,de]}),e[102]=se,e[103]=de,e[104]=fe):fe=e[104];let pe;e[105]!==ie||e[106]!==fe?(pe=(0,$.jsxs)(Yt,{className:`max-w-md`,children:[ie,fe]}),e[105]=ie,e[106]=fe,e[107]=pe):pe=e[107];let me;e[108]!==U||e[109]!==W||e[110]!==pe?(me=(0,$.jsx)(Qt,{open:U,onOpenChange:W,children:pe}),e[108]=U,e[109]=W,e[110]=pe,e[111]=me):me=e[111];let he;return e[112]!==V||e[113]!==H||e[114]!==me?(he=(0,$.jsxs)($.Fragment,{children:[V,H,me]}),e[112]=V,e[113]=H,e[114]=me,e[115]=he):he=e[115],he},xp=e=>{let t=(0,Ii.c)(56),{profile:n,isDefault:r,onEdit:i,onToggleDefault:a,onDelete:o,isReadOnly:s,hasBorder:c}=e,{t:l}=Me(),[u,d]=Q.useState(!1),f=vp[n.icon||`branch`]||`git-branch`,p=yp[n.color||``],m=n.authType||`ssh`,h;t[0]===i?h=t[1]:(h=e=>{e.currentTarget===e.target&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),i())},t[0]=i,t[1]=h);let g=h,_;t[2]!==r||t[3]!==s||t[4]!==o||t[5]!==a||t[6]!==l?(_=e=>(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(e,{onClick:e=>{e.stopPropagation(),a()},children:l(r?`settings.gitIdentities.page.actions.unsetDefault`:`settings.gitIdentities.page.actions.setAsDefault`)}),!s&&o&&(0,$.jsxs)(e,{onClick:e=>{e.stopPropagation(),o()},className:`text-destructive focus:text-destructive`,children:[(0,$.jsx)(X,{name:`delete-bin`,className:`h-4 w-4 mr-px`}),l(`settings.common.actions.delete`)]})]}),t[2]=r,t[3]=s,t[4]=o,t[5]=a,t[6]=l,t[7]=_):_=t[7];let v=_,y=c&&`border-b border-[var(--surface-subtle)]`,b;t[8]===y?b=t[9]:(b=q(`group flex items-center justify-between gap-3 px-4 py-2.5 transition-colors hover:bg-[var(--interactive-hover)]/30 cursor-pointer`,y),t[8]=y,t[9]=b);let x;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(x=e=>{e.preventDefault(),d(!0)},t[10]=x):x=t[10];let S;t[11]!==g||t[12]!==i||t[13]!==b?(S=(0,$.jsx)(`div`,{className:b,onClick:i,role:`button`,tabIndex:0,onKeyDown:g,onContextMenu:x}),t[11]=g,t[12]=i,t[13]=b,t[14]=S):S=t[14];let C;t[15]===p?C=t[16]:(C={color:p},t[15]=p,t[16]=C);let w;t[17]!==f||t[18]!==C?(w=(0,$.jsx)(X,{name:f,className:`w-4 h-4 shrink-0`,style:C}),t[17]=f,t[18]=C,t[19]=w):w=t[19];let T;t[20]===n.name?T=t[21]:(T=(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground truncate`,children:n.name}),t[20]=n.name,t[21]=T);let E;t[22]===m?E=t[23]:(E=(0,$.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:m}),t[22]=m,t[23]=E);let D;t[24]!==r||t[25]!==l?(D=r&&(0,$.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:l(`settings.gitIdentities.page.badge.default`)}),t[24]=r,t[25]=l,t[26]=D):D=t[26];let O;t[27]!==s||t[28]!==l?(O=s&&(0,$.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:l(`settings.agents.sidebar.badge.system`)}),t[27]=s,t[28]=l,t[29]=O):O=t[29];let k;t[30]!==E||t[31]!==D||t[32]!==O||t[33]!==T?(k=(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[T,E,D,O]}),t[30]=E,t[31]=D,t[32]=O,t[33]=T,t[34]=k):k=t[34];let A=m===`token`&&n.host?n.host:n.userEmail,j;t[35]===A?j=t[36]:(j=(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground/60 truncate leading-tight`,children:A}),t[35]=A,t[36]=j);let M;t[37]!==k||t[38]!==j?(M=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[k,j]}),t[37]=k,t[38]=j,t[39]=M):M=t[39];let N;t[40]!==M||t[41]!==w?(N=(0,$.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0`,children:[w,M]}),t[40]=M,t[41]=w,t[42]=N):N=t[42];let P;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,$.jsx)(mr,{asChild:!0,children:(0,$.jsx)(J,{size:`icon`,variant:`ghost`,className:`h-6 w-6 shrink-0 opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100`,onClick:wp,children:(0,$.jsx)(X,{name:`more-2`,className:`h-3.5 w-3.5`})})}),t[43]=P):P=t[43];let F;t[44]===v?F=t[45]:(F=(0,$.jsxs)(cr,{children:[P,(0,$.jsx)(Qn,{align:`end`,className:`w-fit min-w-28`,children:v(Wn)})]}),t[44]=v,t[45]=F);let I;t[46]!==N||t[47]!==F||t[48]!==S?(I=(0,$.jsxs)(Ei,{render:S,children:[N,F]}),t[46]=N,t[47]=F,t[48]=S,t[49]=I):I=t[49];let L;t[50]===v?L=t[51]:(L=(0,$.jsx)(Di,{className:`w-fit min-w-28`,children:v(Oi)}),t[50]=v,t[51]=L);let R;return t[52]!==u||t[53]!==I||t[54]!==L?(R=(0,$.jsxs)(ki,{open:u,onOpenChange:d,children:[I,L]}),t[52]=u,t[53]=I,t[54]=L,t[55]=R):R=t[55],R},Sp=e=>{let t=(0,Ii.c)(21),{credential:n,onImport:r,hasBorder:i}=e,{t:a}=Me(),o;t[0]===n.host?o=t[1]:(o=n.host.split(`/`),t[0]=n.host,t[1]=o);let s=o,c=s.length>=3?s[s.length-1]:n.host,l=n.host.includes(`/`),u=i&&`border-b border-[var(--surface-subtle)]`,d;t[2]===u?d=t[3]:(d=q(`flex items-center justify-between gap-3 px-4 py-2.5 transition-colors hover:bg-[var(--interactive-hover)]/30`,u),t[2]=u,t[3]=d);let f;t[4]===c?f=t[5]:(f=(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground truncate block`,children:c}),t[4]=c,t[5]=f);let p=l?n.host:n.username,m;t[6]===p?m=t[7]:(m=(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground/60 truncate block leading-tight`,children:p}),t[6]=p,t[7]=m);let h;t[8]!==f||t[9]!==m?(h=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[f,m]}),t[8]=f,t[9]=m,t[10]=h):h=t[10];let g;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(X,{name:`download`,className:`h-3 w-3`}),t[11]=g):g=t[11];let _;t[12]===a?_=t[13]:(_=a(`settings.gitIdentities.page.actions.import`),t[12]=a,t[13]=_);let v;t[14]!==r||t[15]!==_?(v=(0,$.jsxs)(J,{size:`sm`,variant:`ghost`,onClick:r,className:`gap-1 shrink-0`,children:[g,_]}),t[14]=r,t[15]=_,t[16]=v):v=t[16];let y;return t[17]!==v||t[18]!==d||t[19]!==h?(y=(0,$.jsxs)(`div`,{className:d,children:[h,v]}),t[17]=v,t[18]=d,t[19]=h,t[20]=y):y=t[20],y};function Cp(e){return{profiles:e.profiles,globalIdentity:e.globalIdentity,defaultGitIdentityId:e.defaultGitIdentityId,deleteProfile:e.deleteProfile,loadProfiles:e.loadProfiles,loadGlobalIdentity:e.loadGlobalIdentity,loadDiscoveredCredentials:e.loadDiscoveredCredentials,loadDefaultGitIdentityId:e.loadDefaultGitIdentityId,setDefaultGitIdentityId:e.setDefaultGitIdentityId,getUnimportedCredentials:e.getUnimportedCredentials}}function wp(e){return e.stopPropagation()}function Tp(){let e=(0,Ii.c)(32),{t}=Me(),{settings:n}=xr(),r=vt(),i;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=o(),e[0]=i):i=e[0];let a=i,s;e[1]===n?s=e[2]:(s={mutationFn:async e=>{let t=o();if(await n.save({questionAutoDelegateEnabled:e}),t!==o())throw Error(`Runtime changed`);await ut()}},e[1]=n,e[2]=s);let c=we(s,w),l=c.reset,u,d;e[3]===l?(u=e[4],d=e[5]):(u=()=>{l()},d=[a,l],e[3]=l,e[4]=u,e[5]=d),(0,Q.useEffect)(u,d);let f;e[6]===t?f=e[7]:(f=t(`settings.chat.questionDelegate.description`),e[6]=t,e[7]=f);let p;e[8]===t?p=e[9]:(p=t(`settings.chat.questionDelegate.label`),e[8]=t,e[9]=p);let m;e[10]===t?m=e[11]:(m=t(`settings.chat.questionDelegate.label`),e[10]=t,e[11]=m);let h=r.data?.snapshot.enabled??!0,g=c.isPending||!r.data||r.isError,_;e[12]===c?_=e[13]:(_=e=>c.mutate(e),e[12]=c,e[13]=_);let v;e[14]!==p||e[15]!==m||e[16]!==h||e[17]!==g||e[18]!==_?(v=(0,$.jsx)(Qr,{itemId:`chat.question-auto-delegate`,label:p,ariaLabel:m,checked:h,disabled:g,onChange:_}),e[14]=p,e[15]=m,e[16]=h,e[17]=g,e[18]=_,e[19]=v):v=e[19];let y;e[20]!==c.isPending||e[21]!==t?(y=c.isPending?(0,$.jsx)(`div`,{className:`oc-settings-group-row typography-meta text-muted-foreground`,role:`status`,children:t(`settings.common.actions.saving`)}):null,e[20]=c.isPending,e[21]=t,e[22]=y):y=e[22];let b;e[23]!==r||e[24]!==c||e[25]!==t?(b=r.isError||c.isError?(0,$.jsxs)(`div`,{className:`oc-settings-group-row flex flex-wrap items-center gap-2`,role:`alert`,children:[(0,$.jsx)(`span`,{className:`typography-meta text-[var(--status-error)]`,children:t(c.isError?`settings.chat.questionDelegate.saveFailed`:`chat.questionDelegate.loadFailed`)}),(0,$.jsx)(J,{variant:`ghost`,size:`xs`,disabled:c.isPending,onClick:()=>c.isError?c.mutate(c.variables??!0):void r.refetch(),children:t(`chat.questionDelegate.retry`)})]}):null,e[23]=r,e[24]=c,e[25]=t,e[26]=b):b=e[26];let x;return e[27]!==v||e[28]!==y||e[29]!==b||e[30]!==f?(x=(0,$.jsxs)(vi,{description:f,children:[v,y,b]}),e[27]=v,e[28]=y,e[29]=b,e[30]=f,e[31]=x):x=e[31],x}var Ep=e=>{let t=(0,Ii.c)(12),{isMobile:n,itemId:r,label:i,description:a,descriptionPlacement:o,children:s,className:c,copyClassName:l,controlClassName:u}=e,d=n&&`oc-mobile-settings-detail-group`,f;t[0]===d?f=t[1]:(f=q(`oc-settings-detail-group`,d),t[0]=d,t[1]=f);let p;return t[2]!==s||t[3]!==c||t[4]!==u||t[5]!==l||t[6]!==a||t[7]!==o||t[8]!==r||t[9]!==i||t[10]!==f?(p=(0,$.jsx)(Jr,{itemId:r,label:i,description:a,descriptionPlacement:o,groupClassName:f,className:c,copyClassName:l,controlClassName:u,children:s}),t[2]=s,t[3]=c,t[4]=u,t[5]=l,t[6]=a,t[7]=o,t[8]=r,t[9]=i,t[10]=f,t[11]=p):p=t[11],p},Dp=e=>{let t=(0,Ii.c)(9),{isMobile:n,label:r,children:i,description:a,className:o,cardClassName:s}=e,c=n&&`oc-mobile-settings-detail-group`,l;t[0]!==o||t[1]!==c?(l=q(`oc-settings-detail-group`,c,o),t[0]=o,t[1]=c,t[2]=l):l=t[2];let u;return t[3]!==s||t[4]!==i||t[5]!==a||t[6]!==r||t[7]!==l?(u=(0,$.jsx)(vi,{label:r,description:a,className:l,cardClassName:s,children:i}),t[3]=s,t[4]=i,t[5]=a,t[6]=r,t[7]=l,t[8]=u):u=t[8],u},Op=e=>{let t=(0,Ii.c)(8),{isMobile:n,itemId:r,label:i,mobileLabel:a,description:o,children:s,className:c,copyClassName:l,controlClassName:u}=e,d=n&&a!==void 0?a:i,f;return t[0]!==s||t[1]!==c||t[2]!==u||t[3]!==l||t[4]!==o||t[5]!==r||t[6]!==d?(f=(0,$.jsx)(Nr,{itemId:r,label:d,description:o,className:c,copyClassName:l,controlClassName:u,children:s}),t[0]=s,t[1]=c,t[2]=u,t[3]=l,t[4]=o,t[5]=r,t[6]=d,t[7]=f):f=t[7],f},kp=e=>{let t=(0,Ii.c)(17),{selected:n,onSelect:r,label:i,ariaLabel:a}=e,o;t[0]===r?o=t[1]:(o=e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),r())},t[0]=r,t[1]=o);let s;t[2]!==a||t[3]!==r||t[4]!==n?(s=(0,$.jsx)(Ks,{checked:n,onChange:r,ariaLabel:a}),t[2]=a,t[3]=r,t[4]=n,t[5]=s):s=t[5];let c=n?`text-foreground`:`text-foreground/50`,l;t[6]===c?l=t[7]:(l=q(`typography-ui-label font-normal`,c),t[6]=c,t[7]=l);let u;t[8]!==i||t[9]!==l?(u=(0,$.jsx)(`span`,{className:l,children:i}),t[8]=i,t[9]=l,t[10]=u):u=t[10];let d;return t[11]!==r||t[12]!==n||t[13]!==o||t[14]!==s||t[15]!==u?(d=(0,$.jsxs)(`div`,{className:`oc-settings-group-row group flex cursor-pointer items-center gap-2 text-left`,role:`button`,tabIndex:0,"aria-pressed":n,onClick:r,onKeyDown:o,children:[s,u]}),t[11]=r,t[12]=n,t[13]=o,t[14]=s,t[15]=u,t[16]=d):d=t[16],d},Ap=[{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`}],jp=[{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`}],Mp=[{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`}],Np=`OpenChamber - AI Coding Assistant`,Pp=[{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`}],Fp=[{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`}],Ip=e=>e===`portrait`||e===`landscape`?e:`system`,Lp=[{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`}],Rp=[{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`}],zp=[{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`}],Bp=[{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`}],Vp=[{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`}],Hp=[{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`}],Up=[{id:`steer`,labelKey:`settings.openchamber.visual.option.followUpBehavior.steer.label`},{id:`queue`,labelKey:`settings.openchamber.visual.option.followUpBehavior.queue.label`}],Wp=e=>e===`markdown`?`markdown`:`plain`,Gp=({visibleSettings:e,mobile:t})=>{let{locale:n,locales:r,setLocale:i,label:a,t:o}=Me(),s=Q.useCallback(e=>o(e),[o]),{isMobile:c}=yr(),f=t??c,{browserTab:p}=si(),m=d(),h=K(e=>e.showReasoningTraces),g=K(e=>e.sessionTitleRefreshEnabled),_=K(e=>e.setSessionTitleRefreshEnabled),v=K(e=>e.sessionGoalEnabled),y=K(e=>e.setSessionGoalEnabled),x=K(e=>e.sessionGoalDefaultBudgetEnabled),S=K(e=>e.setSessionGoalDefaultBudgetEnabled),C=K(e=>e.sessionGoalDefaultBudget),w=K(e=>e.setSessionGoalDefaultBudget),T=K(e=>e.setShowReasoningTraces),E=K(e=>e.collapsibleThinkingBlocks),D=K(e=>e.setCollapsibleThinkingBlocks),A=K(e=>e.mermaidRenderingMode),j=K(e=>e.setMermaidRenderingMode),P=K(e=>e.userMessageRenderingMode),F=K(e=>e.setUserMessageRenderingMode),I=K(e=>e.collapsibleUserMessages),L=K(e=>e.setCollapsibleUserMessages),R=K(e=>e.stickyUserHeader),B=K(e=>e.promptNavigatorEnabled),V=K(e=>e.setStickyUserHeader),H=K(e=>e.setPromptNavigatorEnabled),U=K(e=>e.expandedEditorToolbar),W=K(e=>e.setExpandedEditorToolbar),ee=wr(e=>e.enabled),G=wr(e=>e.setEnabled),te=K(e=>e.wideChatLayoutEnabled),ne=K(e=>e.setWideChatLayoutEnabled),re=K(e=>e.codeBlockLineWrap),ie=K(e=>e.setCodeBlockLineWrap),ae=K(e=>e.chatRenderMode),oe=K(e=>e.setChatRenderMode),se=K(e=>e.activityRenderMode),ce=K(e=>e.setActivityRenderMode),le=K(e=>e.fontSize),ue=K(e=>e.setFontSize),de=K(e=>e.codeFontSize),fe=K(e=>e.setCodeFontSize),pe=K(e=>e.terminalFontSize),me=K(e=>e.setTerminalFontSize),he=K(e=>e.editorFontSize),ge=K(e=>e.setEditorFontSize),xe=K(e=>e.uiFont),Se=K(e=>e.setUiFont),Ce=K(e=>e.monoFont),we=K(e=>e.setMonoFont),Te=K(e=>e.padding),Ee=K(e=>e.setPadding),De=K(e=>e.inputBarOffset),Oe=K(e=>e.setInputBarOffset),ke=K(e=>e.mobileKeyboardMode),Ae=K(e=>e.setMobileKeyboardMode),je=K(e=>e.diffLayoutPreference),Ne=K(e=>e.setDiffLayoutPreference),Pe=K(e=>e.showTerminalQuickKeysOnDesktop),Fe=K(e=>e.setShowTerminalQuickKeysOnDesktop),Ie=K(e=>e.fileEditorKeymap),Le=K(e=>e.setFileEditorKeymap),Re=z(e=>e.followUpBehavior),ze=z(e=>e.setFollowUpBehavior),Be=K(e=>e.persistChatDraft),Ve=K(e=>e.setPersistChatDraft),He=K(e=>e.inputSpellcheckEnabled),Ue=K(e=>e.setInputSpellcheckEnabled),We=K(e=>e.showToolFileIcons),Ge=K(e=>e.setShowToolFileIcons),Ke=K(e=>e.showTurnChangedFiles),qe=K(e=>e.setShowTurnChangedFiles),Je=K(e=>e.showExpandedBashTools),Ye=K(e=>e.setShowExpandedBashTools),Xe=K(e=>e.showSubagentTaskDetails),Ze=K(e=>e.setShowSubagentTaskDetails),Qe=K(e=>e.timeFormatPreference),$e=K(e=>e.setTimeFormatPreference),et=K(e=>e.weekStartPreference),tt=K(e=>e.setWeekStartPreference),nt=K(e=>e.showSplitAssistantMessageActions),rt=K(e=>e.setShowSplitAssistantMessageActions),it=K(e=>e.showAssistantTps),at=K(e=>e.setShowAssistantTps),ot=di(e=>e.sidebarBrandName),st=di(e=>e.setSidebarBrandName),ct=K(e=>e.allowPromptingSubagentSessions),lt=K(e=>e.setAllowPromptingSubagentSessions),ut=Mt(e=>e.settingsMessageStreamTransport),dt=Mt(e=>e.setSettingsMessageStreamTransport),ft=ut,pt=Mt(e=>e.settingsDefaultFileViewerPreview),mt=Mt(e=>e.setSettingsDefaultFileViewerPreview),ht=K(e=>e.isSettingsDialogOpen),{themeMode:gt,setThemeMode:_t,availableThemes:vt,customThemesLoading:yt,reloadCustomThemes:bt,lightThemeId:xt,darkThemeId:St,setLightThemePreference:Ct,setDarkThemePreference:wt}=vr(),[Tt,Et]=Q.useState(!1),[Dt,Ot]=Q.useState(!1),[kt,At]=Q.useState(!1),jt=Q.useMemo(()=>u()&&typeof window<`u`&&window.__OPENCHAMBER_ELECTRON__?.macVibrancySupported===!0,[]),Nt=typeof window<`u`&&window.__OPENCHAMBER_ELECTRON__?.macVibrancy===!0,[Pt,Ft]=Q.useState(Nt),[It,Lt]=Q.useState(!1),zt=Q.useMemo(()=>u()&&typeof window<`u`&&window.__OPENCHAMBER_PLATFORM__===`darwin`,[]),Bt=K(e=>e.dockBadgeEnabled),Vt=K(e=>e.setDockBadgeEnabled),[Ht,Ut]=Q.useState(0),Wt=K(e=>e.reportUsage),Gt=K(e=>e.setReportUsage),Kt=Q.useCallback(e=>{Gt(e),M({reportUsage:e})},[Gt]),$t=ht&&(!e||e.includes(`chatRenderMode`));Q.useEffect(()=>{if(!$t)return;let e=null,t=Date.now(),n=()=>{let r=Date.now();r-t>=420&&(Ut(e=>(e+1)%24),t=r),e=requestAnimationFrame(n)};(typeof document>`u`||document.visibilityState===`visible`)&&(e=requestAnimationFrame(n));let r=()=>{document.visibilityState===`visible`&&e===null?e=requestAnimationFrame(n):document.visibilityState!==`visible`&&e!==null&&(cancelAnimationFrame(e),e=null)};return document.addEventListener(`visibilitychange`,r),()=>{document.removeEventListener(`visibilitychange`,r),e!==null&&cancelAnimationFrame(e)}},[$t]);let en=Q.useCallback(e=>{F(e),M({userMessageRenderingMode:e})},[F]),nn=Q.useCallback(e=>{V(e),M({stickyUserHeader:e})},[V]),on=Q.useCallback(e=>{H(e),M({promptNavigatorEnabled:e})},[H]),cn=Q.useCallback(e=>{W(e),M({expandedEditorToolbar:e})},[W]),un=Q.useCallback(e=>{L(e),M({collapsibleUserMessages:e})},[L]),gn=Q.useCallback(e=>{ne(e),M({wideChatLayoutEnabled:e})},[ne]),_n=Q.useCallback(e=>{rt(e),M({showSplitAssistantMessageActions:e})},[rt]),vn=Q.useCallback(e=>{at(e),M({showAssistantTps:e})},[at]),yn=Q.useCallback(e=>{Ue(e),M({inputSpellcheckEnabled:e})},[Ue]),bn=Q.useCallback(e=>{oe(e),M({chatRenderMode:e})},[oe]),xn=Q.useCallback(e=>{dt(e),M({messageStreamTransport:e})},[dt]),Sn=Q.useCallback(e=>{ce(e),M({activityRenderMode:e})},[ce]),Cn=Q.useCallback(e=>{j(e),M({mermaidRenderingMode:e})},[j]),wn=Q.useCallback(e=>{Ge(e),M({showToolFileIcons:e})},[Ge]),Tn=Q.useCallback(e=>{qe(e),M({showTurnChangedFiles:e})},[qe]),En=Q.useCallback(e=>{mt(e),M({defaultFileViewerPreview:e}),window.dispatchEvent(new CustomEvent(`openchamber:file-viewer-preview-mode-changed`,{detail:{enabled:e}}))},[mt]),Dn=Q.useCallback(e=>{Ye(e),M({showExpandedBashTools:e})},[Ye]),On=Q.useCallback(e=>{Ze(e),M({showSubagentTaskDetails:e})},[Ze]),kn=Q.useCallback(e=>{$e(e),M({timeFormatPreference:e})},[$e]),An=Q.useCallback(e=>{tt(e),M({weekStartPreference:e})},[tt]),jn=Q.useMemo(()=>vt.filter(e=>e.metadata.variant===`light`).sort((e,t)=>e.metadata.name.localeCompare(t.metadata.name)),[vt]),Mn=Q.useMemo(()=>vt.filter(e=>e.metadata.variant===`dark`).sort((e,t)=>e.metadata.name.localeCompare(t.metadata.name)),[vt]),Nn=Q.useMemo(()=>jn.find(e=>e.metadata.id===xt)??jn[0],[jn,xt]),Pn=Q.useMemo(()=>Mn.find(e=>e.metadata.id===St)??Mn[0],[Mn,St]),Fn=Q.useCallback((e,t)=>{let n=t===`dark`?` Dark`:` Light`;return e.endsWith(n)?e.slice(0,-n.length):e},[]),Z=t=>t===`splitAssistantMessageActions`||t===`showToolFileIcons`?!1:!e||e.includes(t),In=async()=>{if(!kt){At(!0);try{await Rt(),Ot(!1),Y.success(o(`settings.openchamber.visual.transcriptCache.toast.cleared`))}catch{Y.error(o(`settings.openchamber.visual.transcriptCache.toast.failed`))}finally{At(!1)}}},Ln=k(),Rn=Er()&&Z(`iosNativeUi`),zn=Z(`theme`)&&!Ln,Bn=Z(`theme`)||Z(`timeFormat`)||Z(`weekStart`),Vn=Ln?Bn||Z(`sidebarBrand`):Z(`theme`)||Z(`sidebarBrand`)||Z(`pwaInstallName`)||Z(`pwaOrientation`)||Z(`mobileKeyboardMode`)||Z(`timeFormat`)||Z(`weekStart`)||Rn,Hn=Z(`fontSize`)||Z(`codeFontSize`)||Z(`terminalFontSize`)||Z(`editorFontSize`)||Z(`spacing`)||Z(`inputBarOffset`),Un=Z(`terminalQuickKeys`)&&!f||Z(`fileEditorKeymap`)||Z(`expandedEditorToolbar`),Wn=Z(`mermaidRendering`)||Z(`questionAutoDelegate`)||Z(`userMessageRendering`)||Z(`chatRenderMode`)||Z(`messageTransport`)||Z(`activityRenderMode`)&&ae===`sorted`||Z(`collapsibleUserMessages`)||Z(`stickyUserHeader`)||Z(`promptNavigatorEnabled`)&&!Ln||Z(`wideChatLayout`)||Z(`codeBlockLineWrap`)||Z(`splitAssistantMessageActions`)||Z(`showAssistantTps`)||Z(`subagentReadOnlyBanner`)||Z(`diffLayout`)||Z(`dotfiles`)||Z(`fileViewerPreview`)||Z(`reasoning`)||Z(`followUpBehavior`)||Z(`persistDraft`)||Z(`showToolFileIcons`)||Z(`showSubagentTaskDetails`)||Z(`expandedTools`)||!f&&Z(`inputSpellcheck`),Gn=Z(`pwaInstallName`)&&N()&&p&&!u()&&!Ln,Kn=Z(`pwaOrientation`)&&N()&&!u()&&!Ln,qn=Z(`mobileKeyboardMode`)&&N()&&!u()&&!Ln&&ye(),[Jn,Yn]=Q.useState(``),[Xn,Zn]=Q.useState(`system`),Qn=Q.useMemo(()=>{let e=Vp.find(e=>e.id===Qe);return s(e?.labelKey??`settings.openchamber.visual.option.timeFormat.auto.label`)},[Qe,s]),$n=Q.useMemo(()=>{let e=Hp.find(e=>e.id===et);return s(e?.labelKey??`settings.openchamber.visual.option.weekStart.auto.label`)},[et,s]),er=Q.useMemo(()=>{let e=Pp.find(e=>e.id===Xn);return e?s(e.labelKey):void 0},[Xn,s]),tr=Q.useMemo(()=>{let e=Fp.find(e=>e.id===ke);return e?s(e.labelKey):void 0},[ke,s]),nr=Q.useCallback(async e=>{if(typeof window>`u`)return;let t=window,n=e.trim().replace(/\s+/g,` `).slice(0,64);if(await M({pwaAppName:n}),typeof t.__OPENCHAMBER_SET_PWA_INSTALL_NAME__==`function`){let e=t.__OPENCHAMBER_SET_PWA_INSTALL_NAME__(n);Yn(e);return}Yn(n||Np),t.__OPENCHAMBER_UPDATE_PWA_MANIFEST__?.()},[]),rr=Q.useCallback(async e=>{if(typeof window>`u`)return;let t=window,n=Ip(e);if(await M({pwaOrientation:n}),typeof t.__OPENCHAMBER_SET_PWA_ORIENTATION__==`function`){let e=t.__OPENCHAMBER_SET_PWA_ORIENTATION__(n);Zn(e);return}Zn(n),t.__OPENCHAMBER_UPDATE_PWA_MANIFEST__?.()},[]);return Q.useEffect(()=>{if(typeof window>`u`||!Gn&&!Kn&&!qn)return;let e=!1;return(async()=>{try{let t=await l(`/api/config/settings`,{method:`GET`,headers:{Accept:`application/json`},cache:`no-store`});if(!t.ok){e||Yn(Np);return}let n=await t.json().catch(()=>({})),r=(typeof n?.pwaAppName==`string`?n.pwaAppName:``).trim().replace(/\s+/g,` `).slice(0,64),i=Ip(n?.pwaOrientation),a=ve(n?.mobileKeyboardMode);e||(Gn&&Yn(r||Np),Kn&&Zn(i),qn&&Ae(a))}catch{e||(Gn&&Yn(Np),Kn&&Zn(`system`),qn&&Ae(`native`))}})(),()=>{e=!0}},[Ae,qn,Gn,Kn]),(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`oc-settings-section-stack`,children:[Vn&&(0,$.jsxs)($.Fragment,{children:[zn&&(0,$.jsxs)(Dp,{isMobile:f,label:(0,$.jsxs)(`div`,{className:`flex w-full min-w-0 items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{children:o(`settings.openchamber.visual.section.colorMode`)}),(0,$.jsxs)(`div`,{className:`inline-flex shrink-0 items-center gap-1`,children:[(0,$.jsx)(`button`,{type:`button`,"data-settings-item":`appearance.reload-themes`,disabled:yt||Tt,onClick:()=>{let e=Date.now();Et(!0),bt().finally(()=>{let t=Date.now()-e;if(t<500){window.setTimeout(()=>{Et(!1)},500-t);return}Et(!1)})},className:`inline-flex items-center typography-micro font-normal text-muted-foreground underline decoration-[1px] underline-offset-2 hover:text-foreground disabled:cursor-not-allowed disabled:text-muted-foreground/60`,children:o(Tt?`settings.openchamber.visual.actions.reloadingThemes`:`settings.openchamber.visual.actions.reloadThemes`)}),(0,$.jsxs)(hn,{children:[(0,$.jsx)(pn,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:`flex items-center justify-center rounded-md p-0.5 text-muted-foreground/70 hover:text-foreground`,"aria-label":o(`settings.openchamber.visual.field.themeImportInfoAria`),children:(0,$.jsx)(X,{name:`information`,className:`h-3.5 w-3.5`})})}),(0,$.jsx)(mn,{sideOffset:8,children:o(`settings.openchamber.visual.field.themeImportInfoTooltip`)})]})]})]}),children:[(0,$.jsx)(Op,{isMobile:f,itemId:`appearance.color-mode`,label:o(`settings.openchamber.visual.field.themeMode`),children:(0,$.jsx)(`div`,{className:`flex flex-nowrap items-center justify-end gap-1`,role:`group`,"aria-label":o(`settings.openchamber.visual.field.themeMode`),children:Ap.map(e=>(0,$.jsx)(J,{variant:`chip`,size:`xs`,"aria-pressed":gt===e.value,className:`oc-mobile-settings-chip shrink-0 !font-normal`,onClick:()=>_t(e.value),children:s(e.labelKey)},e.value))})}),(0,$.jsx)(Op,{isMobile:f,itemId:`appearance.light-theme`,label:o(`settings.openchamber.visual.field.lightTheme`),children:(0,$.jsxs)(ln,{value:Nn?.metadata.id??``,onValueChange:Ct,children:[(0,$.jsx)(rn,{"aria-label":o(`settings.openchamber.visual.field.selectLightThemeAria`),className:`w-fit`,children:(0,$.jsx)(dn,{placeholder:o(`settings.openchamber.visual.field.selectThemePlaceholder`),children:Nn?Fn(Nn.metadata.name,`light`):void 0})}),(0,$.jsx)(an,{children:jn.map(e=>(0,$.jsx)(tn,{value:e.metadata.id,children:Fn(e.metadata.name,`light`)},e.metadata.id))})]})}),(0,$.jsx)(Op,{isMobile:f,itemId:`appearance.dark-theme`,label:o(`settings.openchamber.visual.field.darkTheme`),children:(0,$.jsxs)(ln,{value:Pn?.metadata.id??``,onValueChange:wt,children:[(0,$.jsx)(rn,{"aria-label":o(`settings.openchamber.visual.field.selectDarkThemeAria`),className:`w-fit`,children:(0,$.jsx)(dn,{placeholder:o(`settings.openchamber.visual.field.selectThemePlaceholder`),children:Pn?Fn(Pn.metadata.name,`dark`):void 0})}),(0,$.jsx)(an,{children:Mn.map(e=>(0,$.jsx)(tn,{value:e.metadata.id,children:Fn(e.metadata.name,`dark`)},e.metadata.id))})]})}),jt&&(0,$.jsxs)(`div`,{"data-settings-item":`appearance.window-transparency`,className:`oc-settings-group-row flex flex-col gap-1.5`,children:[(0,$.jsxs)(`div`,{className:`group flex cursor-pointer items-start gap-2 py-0.5`,role:`button`,tabIndex:0,"aria-pressed":Pt,onClick:()=>{It||Ft(!Pt)},onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),It||Ft(!Pt))},children:[(0,$.jsx)(sn,{checked:Pt,onChange:Ft,disabled:It,ariaLabel:o(`settings.openchamber.visual.field.macVibrancy`)}),(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:o(`settings.openchamber.visual.field.macVibrancy`)}),(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:o(`settings.openchamber.visual.field.macVibrancyHint`)})]})]}),Pt!==Nt&&(0,$.jsx)(`div`,{className:`pl-6`,children:(0,$.jsx)(J,{variant:`outline`,size:`sm`,disabled:It,onClick:()=>{Lt(!0),b(`desktop_set_vibrancy`,{enabled:Pt})},children:o(It?`settings.openchamber.visual.actions.restarting`:`settings.openchamber.visual.actions.saveAndRestart`)})})]}),zt&&(0,$.jsx)(`div`,{"data-settings-item":`appearance.dock-badge`,className:`oc-settings-group-row flex flex-col gap-1.5`,children:(0,$.jsxs)(`div`,{className:`group flex cursor-pointer items-start gap-2 py-0.5`,role:`button`,tabIndex:0,"aria-pressed":Bt,onClick:()=>Vt(!Bt),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),Vt(!Bt))},children:[(0,$.jsx)(sn,{checked:Bt,onChange:Vt,ariaLabel:o(`settings.openchamber.visual.field.dockBadge`)}),(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:o(`settings.openchamber.visual.field.dockBadge`)}),(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:o(`settings.openchamber.visual.field.dockBadgeHint`)})]})]})})]}),Rn&&(0,$.jsx)(Dp,{isMobile:f,children:(0,$.jsx)(Qr,{itemId:`appearance.ios-native-ui`,checked:ee,onChange:G,label:o(`settings.openchamber.visual.field.iosNativeUi`),description:o(`settings.openchamber.visual.field.iosNativeUiHint`),ariaLabel:o(`settings.openchamber.visual.field.iosNativeUi`)})}),Bn&&(0,$.jsxs)(Dp,{isMobile:f,label:o(`settings.openchamber.visual.section.localization`),children:[(0,$.jsx)(Op,{isMobile:f,itemId:`appearance.language`,label:o(`settings.appearance.language.label`),description:o(`settings.appearance.language.description`),children:(0,$.jsxs)(ln,{value:n,onValueChange:e=>i(e),children:[(0,$.jsx)(rn,{"aria-label":o(`settings.appearance.language.select`),className:`w-fit`,children:(0,$.jsx)(dn,{children:a(n)})}),(0,$.jsx)(an,{children:r.map(e=>(0,$.jsx)(tn,{value:e,children:a(e)},e))})]})}),(Z(`timeFormat`)||Z(`weekStart`))&&(0,$.jsxs)($.Fragment,{children:[Z(`timeFormat`)&&(0,$.jsx)(Op,{isMobile:f,itemId:`appearance.time-format`,label:o(`settings.openchamber.visual.field.timeFormat`),children:(0,$.jsxs)(ln,{value:Qe,onValueChange:e=>kn(e),children:[(0,$.jsx)(rn,{"aria-label":o(`settings.openchamber.visual.field.selectTimeFormatAria`),className:`w-fit`,children:(0,$.jsx)(dn,{children:Qn})}),(0,$.jsx)(an,{children:Vp.map(e=>(0,$.jsx)(tn,{value:e.id,children:s(e.labelKey)},e.id))})]})}),Z(`weekStart`)&&(0,$.jsx)(Op,{isMobile:f,itemId:`appearance.week-start`,label:o(`settings.openchamber.visual.field.weekStartsOn`),children:(0,$.jsxs)(ln,{value:et,onValueChange:e=>An(e),children:[(0,$.jsx)(rn,{"aria-label":o(`settings.openchamber.visual.field.selectWeekStartAria`),className:`w-fit`,children:(0,$.jsx)(dn,{children:$n})}),(0,$.jsx)(an,{children:Hp.map(e=>(0,$.jsx)(tn,{value:e.id,children:s(e.labelKey)},e.id))})]})})]})]}),Z(`sidebarBrand`)&&(0,$.jsx)(Ep,{isMobile:f,itemId:`appearance.sidebar-brand`,label:o(`settings.openchamber.visual.field.sidebarBrand`),description:o(`settings.openchamber.visual.field.sidebarBrandHint`),descriptionPlacement:`outside`,children:(0,$.jsx)(fn,{value:ot,onChange:e=>st(e.target.value),maxLength:64,"aria-label":o(`settings.openchamber.visual.field.sidebarBrandAria`)})}),(Gn||Kn||qn)&&(0,$.jsxs)($.Fragment,{children:[Gn&&(0,$.jsxs)(Ep,{isMobile:f,itemId:`appearance.pwa-install-name`,label:o(`settings.openchamber.visual.field.installAppName`),description:o(`settings.openchamber.visual.field.installAppNameHint`),children:[(0,$.jsx)(fn,{value:Jn,onChange:e=>{Yn(e.target.value)},onBlur:()=>{nr(Jn)},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),nr(Jn))},maxLength:64,"aria-label":o(`settings.openchamber.visual.field.pwaInstallAppNameAria`)}),(0,$.jsx)(J,{size:`sm`,type:`button`,variant:`ghost`,onClick:()=>{Yn(Np),nr(``)},className:`h-7 w-7 px-0 text-muted-foreground hover:text-foreground`,"aria-label":o(`settings.openchamber.visual.actions.resetInstallAppNameAria`),title:o(`settings.common.actions.reset`),children:(0,$.jsx)(X,{name:`restart`,className:`h-3.5 w-3.5`})})]}),Kn&&(0,$.jsxs)(Ep,{isMobile:f,itemId:`appearance.pwa-orientation`,label:o(`settings.openchamber.visual.field.installOrientation`),description:o(`settings.openchamber.visual.field.installOrientationHint`),descriptionPlacement:`outside`,children:[(0,$.jsxs)(ln,{value:Xn,onValueChange:e=>{let t=Ip(e);Zn(t),rr(t)},children:[(0,$.jsx)(rn,{"aria-label":o(`settings.openchamber.visual.field.pwaInstallOrientationAria`),className:`w-full`,children:(0,$.jsx)(dn,{placeholder:o(`settings.openchamber.visual.field.selectOrientationPlaceholder`),children:er})}),(0,$.jsx)(an,{children:Pp.map(e=>(0,$.jsx)(tn,{value:e.id,children:s(e.labelKey)},e.id))})]}),(0,$.jsx)(J,{size:`sm`,type:`button`,variant:`ghost`,onClick:()=>{Zn(`system`),rr(`system`)},disabled:Xn===`system`,className:`h-7 w-7 px-0 text-muted-foreground hover:text-foreground`,"aria-label":o(`settings.openchamber.visual.actions.resetInstallOrientationAria`),title:o(`settings.common.actions.reset`),children:(0,$.jsx)(X,{name:`restart`,className:`h-3.5 w-3.5`})})]}),qn&&(0,$.jsxs)(Ep,{isMobile:f,itemId:`appearance.mobile-keyboard-mode`,label:o(`settings.openchamber.visual.field.mobileKeyboardMode`),description:o(`settings.openchamber.visual.field.mobileKeyboardModeHint`),descriptionPlacement:`outside`,children:[(0,$.jsxs)(ln,{value:ke,onValueChange:e=>{let t=ve(e);Ae(t),M({mobileKeyboardMode:t})},children:[(0,$.jsx)(rn,{"aria-label":o(`settings.openchamber.visual.field.mobileKeyboardModeAria`),className:`w-full`,children:(0,$.jsx)(dn,{placeholder:o(`settings.openchamber.visual.field.selectMobileKeyboardModePlaceholder`),children:tr})}),(0,$.jsx)(an,{children:Fp.map(e=>(0,$.jsx)(tn,{value:e.id,children:s(e.labelKey)},e.id))})]}),(0,$.jsx)(J,{size:`sm`,type:`button`,variant:`ghost`,onClick:()=>{Ae(`native`),M({mobileKeyboardMode:`native`})},disabled:ke===`native`,className:`h-7 w-7 px-0 text-muted-foreground hover:text-foreground`,"aria-label":o(`settings.openchamber.visual.actions.resetMobileKeyboardModeAria`),title:o(`settings.common.actions.reset`),children:(0,$.jsx)(X,{name:`restart`,className:`h-3.5 w-3.5`})})]})]})]}),Hn&&(0,$.jsx)($.Fragment,{children:(0,$.jsx)(Dp,{isMobile:f,label:o(`settings.openchamber.visual.section.spacingAndLayout`),children:(0,$.jsxs)($.Fragment,{children:[Z(`fontSize`)&&!f&&(0,$.jsxs)(Op,{isMobile:f,label:o(`settings.openchamber.visual.field.interfaceFont`),children:[(0,$.jsxs)(ln,{value:xe,onValueChange:e=>Se(e),children:[(0,$.jsx)(rn,{"aria-label":o(`settings.openchamber.visual.field.selectInterfaceFontAria`),className:`w-[13rem]`,children:(0,$.jsx)(dn,{children:_e.find(e=>e.id===xe)?.label})}),(0,$.jsx)(an,{children:_e.map(e=>(0,$.jsx)(tn,{value:e.id,children:(0,$.jsx)(`span`,{style:{fontFamily:e.stack},children:e.label})},e.id))})]}),(0,$.jsx)(J,{size:`sm`,type:`button`,variant:`ghost`,onClick:()=>Se(`system`),disabled:xe===`system`,className:`h-7 w-7 px-0 text-muted-foreground hover:text-foreground`,"aria-label":o(`settings.openchamber.visual.actions.resetInterfaceFontAria`),title:o(`settings.common.actions.reset`),children:(0,$.jsx)(X,{name:`restart`,className:`h-3.5 w-3.5`})})]}),Z(`terminalFontSize`)&&(0,$.jsxs)(Op,{isMobile:f,itemId:`appearance.code-font`,label:o(`settings.openchamber.visual.field.codeFont`),children:[(0,$.jsxs)(ln,{value:Ce,onValueChange:e=>we(e),children:[(0,$.jsx)(rn,{"aria-label":o(`settings.openchamber.visual.field.selectCodeFontAria`),className:`w-full max-w-[13rem]`,children:(0,$.jsx)(dn,{children:be.find(e=>e.id===Ce)?.label})}),(0,$.jsx)(an,{children:be.map(e=>(0,$.jsx)(tn,{value:e.id,children:(0,$.jsx)(`span`,{style:{fontFamily:e.stack},children:e.label})},e.id))})]}),(0,$.jsx)(J,{size:`sm`,type:`button`,variant:`ghost`,onClick:()=>we(`system-mono`),disabled:Ce===`system-mono`,className:`h-7 w-7 px-0 text-muted-foreground hover:text-foreground`,"aria-label":o(`settings.openchamber.visual.actions.resetCodeFontAria`),title:o(`settings.common.actions.reset`),children:(0,$.jsx)(X,{name:`restart`,className:`h-3.5 w-3.5`})})]}),Z(`fontSize`)&&(0,$.jsxs)(Op,{isMobile:f,itemId:`appearance.interface-font-size`,label:o(`settings.openchamber.visual.field.interfaceFontSize`),children:[(0,$.jsx)(Fr,{value:le,onValueChange:ue,min:50,max:200,step:5,"aria-label":o(`settings.openchamber.visual.field.fontSizePercentageAria`),className:`w-16`}),(0,$.jsx)(J,{size:`sm`,type:`button`,variant:`ghost`,onClick:()=>ue(100),disabled:le===100,className:`h-7 w-7 px-0 text-muted-foreground hover:text-foreground`,"aria-label":o(`settings.openchamber.visual.actions.resetFontSizeAria`),title:o(`settings.common.actions.reset`),children:(0,$.jsx)(X,{name:`restart`,className:`h-3.5 w-3.5`})})]}),Z(`codeFontSize`)&&(0,$.jsxs)(Op,{isMobile:f,itemId:`appearance.code-font-size`,label:o(`settings.openchamber.visual.field.codeFontSize`),children:[(0,$.jsx)(Fr,{value:de,onValueChange:fe,min:50,max:200,step:5,"aria-label":o(`settings.openchamber.visual.field.codeFontSizePercentageAria`),className:`w-16`}),(0,$.jsx)(J,{size:`sm`,type:`button`,variant:`ghost`,onClick:()=>fe(100),disabled:de===100,className:`h-7 w-7 px-0 text-muted-foreground hover:text-foreground`,"aria-label":o(`settings.openchamber.visual.actions.resetCodeFontSizeAria`),title:o(`settings.common.actions.reset`),children:(0,$.jsx)(X,{name:`restart`,className:`h-3.5 w-3.5`})})]}),Z(`terminalFontSize`)&&(0,$.jsxs)(Op,{isMobile:f,itemId:`appearance.terminal-font-size`,label:o(`settings.openchamber.visual.field.terminalFontSize`),children:[(0,$.jsx)(Fr,{value:pe,onValueChange:me,min:9,max:52,step:1,className:`w-16`}),(0,$.jsx)(J,{size:`sm`,type:`button`,variant:`ghost`,onClick:()=>me(13),disabled:pe===13,className:`h-7 w-7 px-0 text-muted-foreground hover:text-foreground`,"aria-label":o(`settings.openchamber.visual.actions.resetTerminalFontSizeAria`),title:o(`settings.common.actions.reset`),children:(0,$.jsx)(X,{name:`restart`,className:`h-3.5 w-3.5`})})]}),Z(`editorFontSize`)&&(0,$.jsxs)(Op,{isMobile:f,itemId:`appearance.editor-font-size`,label:o(`settings.openchamber.visual.field.editorFontSize`),children:[(0,$.jsx)(Fr,{value:he,onValueChange:ge,min:9,max:32,step:1,className:`w-16`}),(0,$.jsx)(J,{size:`sm`,type:`button`,variant:`ghost`,onClick:()=>ge(13),disabled:he===13,className:`h-7 w-7 px-0 text-muted-foreground hover:text-foreground`,"aria-label":o(`settings.openchamber.visual.actions.resetEditorFontSizeAria`),title:o(`settings.common.actions.reset`),children:(0,$.jsx)(X,{name:`restart`,className:`h-3.5 w-3.5`})})]}),Z(`spacing`)&&(0,$.jsxs)(Op,{isMobile:f,itemId:`appearance.spacing-density`,label:o(`settings.openchamber.visual.field.spacingDensity`),children:[(0,$.jsx)(Fr,{value:Te,onValueChange:Ee,min:50,max:200,step:5,className:`w-16`}),(0,$.jsx)(J,{size:`sm`,type:`button`,variant:`ghost`,onClick:()=>Ee(100),disabled:Te===100,className:`h-7 w-7 px-0 text-muted-foreground hover:text-foreground`,"aria-label":o(`settings.openchamber.visual.actions.resetSpacingAria`),title:o(`settings.common.actions.reset`),children:(0,$.jsx)(X,{name:`restart`,className:`h-3.5 w-3.5`})})]}),Z(`inputBarOffset`)&&(0,$.jsxs)(Op,{isMobile:f,itemId:`appearance.input-bar-offset`,label:(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{children:o(`settings.openchamber.visual.field.inputBarOffset`)}),(0,$.jsxs)(hn,{children:[(0,$.jsx)(pn,{asChild:!0,children:(0,$.jsx)(X,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(mn,{sideOffset:8,className:`max-w-xs`,children:o(`settings.openchamber.visual.field.inputBarOffsetTooltip`)})]})]}),children:[(0,$.jsx)(Fr,{value:De,onValueChange:Oe,min:0,max:100,step:5,className:`w-16`}),(0,$.jsx)(J,{size:`sm`,type:`button`,variant:`ghost`,onClick:()=>Oe(0),disabled:De===0,className:`h-7 w-7 px-0 text-muted-foreground hover:text-foreground`,"aria-label":o(`settings.openchamber.visual.actions.resetInputBarOffsetAria`),title:o(`settings.common.actions.reset`),children:(0,$.jsx)(X,{name:`restart`,className:`h-3.5 w-3.5`})})]})]})})}),Un&&(0,$.jsx)($.Fragment,{children:(0,$.jsxs)(Dp,{isMobile:f,label:o(`settings.openchamber.visual.section.navigation`),children:[Z(`fileEditorKeymap`)&&(0,$.jsx)(Op,{isMobile:f,itemId:`appearance.file-editor-keymap`,label:o(`settings.openchamber.visual.field.fileEditorKeymap`),children:(0,$.jsx)(`div`,{role:`radiogroup`,"aria-label":o(`settings.openchamber.visual.field.fileEditorKeymap`),className:`flex flex-wrap items-center justify-end gap-x-3 gap-y-1`,children:[`default`,`vim`].map(e=>{let t=Ie===e,n=o(`settings.openchamber.visual.option.fileEditorKeymap.${e}`);return(0,$.jsxs)(`button`,{type:`button`,className:`flex cursor-pointer items-center gap-2 py-0.5 text-left`,role:`radio`,"aria-checked":t,onClick:()=>Le(e),children:[(0,$.jsx)(`span`,{"aria-hidden":!0,className:q(`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`,t?`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:(0,$.jsx)(`span`,{className:q(`block h-[5px] w-[5px] rounded-full bg-white`,!t&&`opacity-0`)})}),(0,$.jsx)(`span`,{className:q(`typography-ui-label font-normal`,t?`text-foreground`:`text-foreground/50`),children:n})]},e)})})}),Z(`expandedEditorToolbar`)&&(0,$.jsx)(Op,{isMobile:f,itemId:`appearance.expanded-editor-toolbar`,label:o(`settings.openchamber.visual.field.expandedEditorToolbar`),children:(0,$.jsx)(sn,{checked:U,onChange:cn,ariaLabel:o(`settings.openchamber.visual.field.expandedEditorToolbarAria`)})}),Z(`terminalQuickKeys`)&&!f&&!u()&&(0,$.jsx)(Op,{isMobile:f,itemId:`appearance.terminal-quick-keys`,label:(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,$.jsx)(`span`,{children:o(`settings.openchamber.visual.field.terminalQuickKeys`)}),(0,$.jsxs)(hn,{children:[(0,$.jsx)(pn,{asChild:!0,children:(0,$.jsx)(X,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(mn,{sideOffset:8,className:`max-w-xs`,children:o(`settings.openchamber.visual.field.terminalQuickKeysTooltip`)})]})]}),children:(0,$.jsx)(sn,{checked:Pe,onChange:Fe,ariaLabel:o(`settings.openchamber.visual.field.terminalQuickKeysAria`)})})]})}),Wn&&(0,$.jsxs)(`div`,{className:`oc-settings-section-stack`,children:[(Z(`userMessageRendering`)||Z(`mermaidRendering`)||Z(`chatRenderMode`)||Z(`messageTransport`)||Z(`activityRenderMode`)&&ae===`sorted`||Z(`diffLayout`)&&!Ln||Z(`followUpBehavior`))&&(0,$.jsxs)(`div`,{className:`grid w-full grid-cols-1 gap-y-[var(--oc-settings-section-stack-gap)]`,children:[Z(`chatRenderMode`)&&(0,$.jsx)(Dp,{isMobile:f,label:o(`settings.openchamber.visual.section.chatRenderMode`),className:`w-full`,cardClassName:`!border-0 !bg-transparent !rounded-none overflow-visible`,children:(0,$.jsx)(`div`,{"data-settings-item":`chat.render-mode`,className:`min-w-0 w-full`,children:(0,$.jsx)(`div`,{role:`radiogroup`,"aria-label":o(`settings.openchamber.visual.section.chatRenderModeAria`),className:`grid w-full grid-cols-1 gap-3 sm:grid-cols-2`,children:Rp.map(e=>{let t=ae===e.id,n=Ht%12;return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>bn(e.id),"aria-pressed":t,className:q(`flex flex-col items-start gap-1 rounded-lg border p-3 text-left transition-colors`,t?`border-primary bg-primary/5`:`border-border hover:border-border/80 hover:bg-muted/50`),children:[(0,$.jsx)(`span`,{className:q(`typography-ui-label`,t?`text-foreground`:`text-muted-foreground`),children:s(e.labelKey)}),(0,$.jsx)(`div`,{className:`mt-2 w-full rounded-md border border-border/60 bg-muted/30 p-2`,children:e.id===`live`?(0,$.jsx)(`div`,{className:`space-y-1.5`,children:[0,1,2].map(e=>{let t=e*3+1,r=n-t+1,i=r<=0?0:r===1?42:r===2?68:92;return(0,$.jsxs)(`div`,{className:q(`flex items-center gap-1.5 transition-all duration-300 motion-reduce:transition-none`,i>0?`translate-y-0 opacity-100`:`translate-y-1 opacity-0`),children:[(0,$.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full bg-muted-foreground/55`}),(0,$.jsx)(`span`,{className:`h-1.5 rounded bg-muted-foreground/30 transition-all duration-300 motion-reduce:transition-none`,style:{width:`${i}%`}})]},e)})}):(0,$.jsx)(`div`,{className:`space-y-1.5`,children:[0,1,2].map(e=>{let t=n>=(e+1)*3;return(0,$.jsxs)(`div`,{className:q(`flex items-center gap-1.5 transition-all duration-300 motion-reduce:transition-none`,t?`translate-y-0 opacity-100`:`translate-y-1 opacity-0`),children:[(0,$.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full bg-muted-foreground/55`}),(0,$.jsx)(`span`,{className:`h-1.5 rounded bg-muted-foreground/30`,style:{width:`92%`}})]},e)})})})]},e.id)})})})}),Z(`messageTransport`)&&(0,$.jsx)(Dp,{isMobile:f,label:o(`settings.openchamber.visual.section.messageStreamTransport`),className:`w-full`,children:(0,$.jsxs)(`div`,{"data-settings-item":`chat.message-transport`,className:`oc-settings-group-row flex flex-col gap-2`,children:[(0,$.jsx)(`div`,{className:`flex flex-wrap items-center gap-1`,children:zp.map(e=>(0,$.jsx)(J,{variant:`chip`,size:`xs`,"aria-pressed":ft===e.id,className:`!font-normal`,onClick:()=>xn(e.id),children:s(e.labelKey)},e.id))}),(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:(()=>{let e=zp.find(e=>e.id===ft);return e?.descriptionKey?s(e.descriptionKey):``})()})]})}),Z(`activityRenderMode`)&&ae===`sorted`&&(0,$.jsx)(Dp,{isMobile:f,label:o(`settings.openchamber.visual.section.activityDefault`),className:`w-full`,children:(0,$.jsx)(`div`,{role:`radiogroup`,"aria-label":o(`settings.openchamber.visual.section.activityDefaultAria`),children:Bp.map(e=>{let t=se===e.id;return(0,$.jsx)(kp,{selected:t,onSelect:()=>Sn(e.id),label:s(e.labelKey),ariaLabel:o(`settings.openchamber.visual.field.activityDefaultModeAria`,{option:s(e.labelKey)})},e.id)})})}),Z(`expandedTools`)&&(0,$.jsx)(Dp,{isMobile:f,label:o(`settings.openchamber.visual.section.showToolsOpenedByDefault`),className:`w-full`,children:(0,$.jsxs)(`div`,{className:`oc-settings-group-row group flex cursor-pointer items-center gap-2`,role:`button`,tabIndex:0,"aria-pressed":Je,onClick:()=>Dn(!Je),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),Dn(!Je))},children:[(0,$.jsx)(sn,{checked:Je,onChange:Dn,ariaLabel:o(`settings.openchamber.visual.field.showExpandedBashToolsAria`)}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:o(`settings.openchamber.visual.field.bash`)})]})}),Z(`userMessageRendering`)&&(0,$.jsx)(Dp,{isMobile:f,label:o(`settings.openchamber.visual.section.userMessageRendering`),className:`w-full`,children:(0,$.jsx)(`div`,{role:`radiogroup`,"aria-label":o(`settings.openchamber.visual.section.userMessageRenderingAria`),children:Lp.map(e=>{let t=Wp(P)===e.id;return(0,$.jsx)(kp,{selected:t,onSelect:()=>en(e.id),label:s(e.labelKey),ariaLabel:o(`settings.openchamber.visual.field.userMessageRenderingAria`,{option:s(e.labelKey)})},e.id)})})}),Z(`mermaidRendering`)&&(0,$.jsx)(Dp,{isMobile:f,label:o(`settings.openchamber.visual.section.mermaidRendering`),className:`w-full`,children:(0,$.jsx)(`div`,{role:`radiogroup`,"aria-label":o(`settings.openchamber.visual.section.mermaidRenderingAria`),children:Mp.map(e=>{let t=A===e.id;return(0,$.jsx)(kp,{selected:t,onSelect:()=>Cn(e.id),label:s(e.labelKey),ariaLabel:o(`settings.openchamber.visual.field.mermaidRenderingAria`,{option:s(e.labelKey)})},e.id)})})}),Z(`diffLayout`)&&!Ln&&(0,$.jsx)(Dp,{isMobile:f,label:o(`settings.openchamber.visual.section.diffLayout`),className:`w-full`,children:(0,$.jsx)(`div`,{role:`radiogroup`,"aria-label":o(`settings.openchamber.visual.section.diffLayoutAria`),children:jp.map(e=>{let t=je===e.id;return(0,$.jsx)(kp,{selected:t,onSelect:()=>Ne(e.id),label:s(e.labelKey),ariaLabel:o(`settings.openchamber.visual.field.diffLayoutAria`,{option:s(e.labelKey)})},e.id)})})}),Z(`followUpBehavior`)&&(0,$.jsx)(Dp,{isMobile:f,label:o(`settings.openchamber.visual.section.followUpBehavior`),className:`w-full`,children:(0,$.jsx)(`div`,{"data-settings-item":`chat.follow-up-behavior`,role:`radiogroup`,"aria-label":o(`settings.openchamber.visual.section.followUpBehaviorAria`),children:Up.map(e=>{let t=Re===e.id;return(0,$.jsx)(kp,{selected:t,onSelect:()=>ze(e.id),label:s(e.labelKey),ariaLabel:o(`settings.openchamber.visual.field.followUpBehaviorAria`,{option:s(e.labelKey)})},e.id)})})})]}),Z(`sessionGoal`)&&!Ln&&(0,$.jsxs)(Dp,{isMobile:f,label:(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{children:o(`settings.openchamber.visual.goal.sectionTitle`)}),(0,$.jsxs)(hn,{children:[(0,$.jsx)(pn,{asChild:!0,children:(0,$.jsx)(X,{name:`information`,className:`h-3.5 w-3.5 cursor-help text-muted-foreground/60`})}),(0,$.jsx)(mn,{sideOffset:8,className:`max-w-sm`,children:o(`settings.openchamber.visual.goal.description`)})]})]}),children:[(0,$.jsx)(Op,{isMobile:f,itemId:`chat.session-goal`,label:o(`settings.openchamber.visual.field.sessionGoal`),children:(0,$.jsx)(sn,{checked:v,onChange:y,ariaLabel:o(`settings.openchamber.visual.field.sessionGoalAria`)})}),(0,$.jsxs)(Op,{isMobile:f,itemId:`chat.session-goal-budget`,label:o(`settings.openchamber.visual.goal.budgetLabel`),children:[(0,$.jsx)(sn,{checked:x,onChange:S,disabled:!v,ariaLabel:o(`settings.openchamber.visual.goal.budgetAria`)}),v&&x?(0,$.jsx)(Fr,{value:C,onValueChange:e=>{typeof e==`number`&&Number.isFinite(e)&&e>0&&w(Math.floor(e))},min:1e3,max:1e8,step:5e4}):null]})]}),Z(`questionAutoDelegate`)&&(0,$.jsx)(Tp,{}),(Z(`sessionAssist`)||Z(`collapsibleUserMessages`)||Z(`stickyUserHeader`)||Z(`promptNavigatorEnabled`)&&!Ln||Z(`wideChatLayout`)||Z(`codeBlockLineWrap`)||Z(`splitAssistantMessageActions`)||Z(`showAssistantTps`)||Z(`subagentReadOnlyBanner`)||Z(`dotfiles`)||Z(`fileViewerPreview`)||Z(`persistDraft`)||Z(`showToolFileIcons`)||Z(`showSubagentTaskDetails`)||Z(`showTurnChangedFiles`)||!f&&Z(`inputSpellcheck`)||Z(`reasoning`))&&(0,$.jsxs)(`div`,{className:`oc-settings-section-stack`,children:[(Z(`sessionAssist`)||Z(`subagentReadOnlyBanner`))&&(0,$.jsxs)(Dp,{isMobile:f,label:(0,$.jsx)(`span`,{"data-settings-item":`chat.session-assistance`,children:o(`settings.openchamber.visual.section.sessionAssistance`)}),children:[Z(`sessionAssist`)&&(0,$.jsxs)(`div`,{"data-settings-item":`chat.session-title-refresh`,className:`group flex cursor-pointer items-center gap-2 py-0.5`,role:`button`,tabIndex:0,"aria-pressed":g,onClick:()=>_(!g),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),_(!g))},children:[(0,$.jsx)(sn,{checked:g,onChange:_,ariaLabel:o(`settings.openchamber.visual.field.sessionTitleRefreshAria`)}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:o(`settings.openchamber.visual.field.sessionTitleRefresh`)})]}),Z(`subagentReadOnlyBanner`)&&(0,$.jsxs)(`div`,{"data-settings-item":`chat.subagent-read-only-banner`,className:`group flex cursor-pointer items-center gap-2 py-0.5`,role:`button`,tabIndex:0,"aria-pressed":ct,onClick:()=>lt(!ct),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),lt(!ct))},children:[(0,$.jsx)(sn,{checked:ct,onChange:lt,ariaLabel:o(`settings.openchamber.visual.field.allowPromptingSubagentSessionsAria`)}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:o(`settings.openchamber.visual.field.allowPromptingSubagentSessions`)})]})]}),Z(`reasoning`)&&(0,$.jsxs)(Dp,{isMobile:f,label:(0,$.jsx)(`span`,{"data-settings-item":`chat.reasoning`,children:o(`settings.openchamber.visual.section.reasoning`)}),children:[Z(`reasoning`)&&(0,$.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":h,onClick:()=>T(!h),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),T(!h))},children:[(0,$.jsx)(sn,{checked:h,onChange:T,ariaLabel:o(`settings.openchamber.visual.field.showReasoningTracesAria`)}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:o(`settings.openchamber.visual.field.showReasoningTraces`)})]}),Z(`reasoning`)&&h&&(0,$.jsxs)(`div`,{className:`group flex cursor-pointer items-center gap-2 py-0.5`,role:`button`,tabIndex:0,"aria-pressed":E,onClick:()=>D(!E),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),D(!E))},children:[(0,$.jsx)(sn,{checked:E,onChange:D,ariaLabel:o(`settings.openchamber.visual.field.collapsibleThinkingBlocksAria`)}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:o(`settings.openchamber.visual.field.collapsibleThinkingBlocks`)})]})]}),(Z(`collapsibleUserMessages`)||Z(`stickyUserHeader`)||Z(`promptNavigatorEnabled`)&&!Ln||Z(`wideChatLayout`)||Z(`splitAssistantMessageActions`)||Z(`showAssistantTps`)||Z(`codeBlockLineWrap`))&&(0,$.jsxs)(Dp,{isMobile:f,label:(0,$.jsx)(`span`,{"data-settings-item":`chat.message-appearance`,children:o(`settings.openchamber.visual.section.messageAppearance`)}),children:[Z(`collapsibleUserMessages`)&&(0,$.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":I,onClick:()=>un(!I),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),un(!I))},children:[(0,$.jsx)(sn,{checked:I,onChange:un,ariaLabel:o(`settings.openchamber.visual.field.collapsibleUserMessagesAria`)}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:o(`settings.openchamber.visual.field.collapsibleUserMessages`)})]}),Z(`stickyUserHeader`)&&(0,$.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":R,onClick:()=>nn(!R),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),nn(!R))},children:[(0,$.jsx)(sn,{checked:R,onChange:nn,ariaLabel:o(`settings.openchamber.visual.field.stickyUserHeaderAria`)}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:o(`settings.openchamber.visual.field.stickyUserHeader`)})]}),Z(`promptNavigatorEnabled`)&&!Ln&&(0,$.jsxs)(`div`,{"data-settings-item":`chat.prompt-navigator`,className:`group flex cursor-pointer items-center gap-2 py-0.5`,role:`button`,tabIndex:0,"aria-pressed":B,onClick:()=>on(!B),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),on(!B))},children:[(0,$.jsx)(sn,{checked:B,onChange:on,ariaLabel:o(`settings.openchamber.visual.field.promptNavigatorEnabledAria`)}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:o(`settings.openchamber.visual.field.promptNavigatorEnabled`)})]}),Z(`wideChatLayout`)&&(0,$.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":te,onClick:()=>gn(!te),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),gn(!te))},children:[(0,$.jsx)(sn,{checked:te,onChange:gn,ariaLabel:o(`settings.openchamber.visual.field.wideChatLayoutAria`)}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:o(`settings.openchamber.visual.field.wideChatLayout`)})]}),Z(`splitAssistantMessageActions`)&&(0,$.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":nt,onClick:()=>_n(!nt),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),_n(!nt))},children:[(0,$.jsx)(sn,{checked:nt,onChange:_n,ariaLabel:o(`settings.openchamber.visual.field.showSplitAssistantMessageActionsAria`)}),(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:o(`settings.openchamber.visual.field.showSplitAssistantMessageActions`)}),(0,$.jsxs)(hn,{children:[(0,$.jsx)(pn,{asChild:!0,children:(0,$.jsx)(X,{name:`information`,className:`h-3.5 w-3.5 cursor-help text-muted-foreground/60`})}),(0,$.jsx)(mn,{sideOffset:8,className:`max-w-xs`,children:o(`settings.openchamber.visual.field.showSplitAssistantMessageActionsTooltip`)})]})]})]}),Z(`showAssistantTps`)&&(0,$.jsxs)(`div`,{"data-settings-item":`chat.assistant-tps`,className:`group flex cursor-pointer items-center gap-2 py-0.5`,role:`button`,tabIndex:0,"aria-pressed":it,onClick:()=>vn(!it),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),vn(!it))},children:[(0,$.jsx)(sn,{checked:it,onChange:vn,ariaLabel:o(`settings.openchamber.visual.field.showAssistantTpsAria`)}),(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:o(`settings.openchamber.visual.field.showAssistantTps`)}),(0,$.jsxs)(hn,{children:[(0,$.jsx)(pn,{asChild:!0,children:(0,$.jsx)(X,{name:`information`,className:`h-3.5 w-3.5 cursor-help text-muted-foreground/60`})}),(0,$.jsx)(mn,{sideOffset:8,className:`max-w-xs`,children:o(`settings.openchamber.visual.field.showAssistantTpsTooltip`)})]})]})]}),Z(`codeBlockLineWrap`)&&(0,$.jsxs)(`div`,{"data-settings-item":`chat.code-block-line-wrap`,className:`group flex cursor-pointer items-center gap-2 py-0.5`,role:`button`,tabIndex:0,"aria-pressed":re,onClick:()=>ie(!re),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),ie(!re))},children:[(0,$.jsx)(sn,{checked:re,onChange:ie,ariaLabel:o(`settings.openchamber.visual.field.codeBlockLineWrapAria`)}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:o(`settings.openchamber.visual.field.codeBlockLineWrap`)})]})]}),(Z(`showToolFileIcons`)||Z(`showTurnChangedFiles`)||Z(`dotfiles`)||Z(`fileViewerPreview`))&&(0,$.jsxs)(Dp,{isMobile:f,label:(0,$.jsx)(`span`,{"data-settings-item":`chat.tools-and-files`,children:o(`settings.openchamber.visual.section.toolsAndFiles`)}),children:[Z(`showToolFileIcons`)&&(0,$.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":We,onClick:()=>wn(!We),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),wn(!We))},children:[(0,$.jsx)(sn,{checked:We,onChange:wn,ariaLabel:o(`settings.openchamber.visual.field.showToolFileIconsAria`)}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:o(`settings.openchamber.visual.field.showToolFileIcons`)})]}),Z(`showSubagentTaskDetails`)&&(0,$.jsxs)(`div`,{"data-settings-item":`chat.subagent-task-details`,className:`group flex cursor-pointer items-start gap-2 py-0.5`,role:`button`,tabIndex:0,"aria-pressed":Xe,onClick:()=>On(!Xe),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),On(!Xe))},children:[(0,$.jsx)(sn,{checked:Xe,onChange:On,ariaLabel:o(`settings.openchamber.visual.field.showSubagentTaskDetailsAria`),className:`mt-0.5`}),(0,$.jsxs)(`span`,{className:`min-w-0 flex flex-col gap-0.5`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:o(`settings.openchamber.visual.field.showSubagentTaskDetails`)}),(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:o(`settings.openchamber.visual.field.showSubagentTaskDetailsHint`)})]})]}),Z(`showTurnChangedFiles`)&&(0,$.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":Ke,onClick:()=>Tn(!Ke),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),Tn(!Ke))},children:[(0,$.jsx)(sn,{checked:Ke,onChange:Tn,ariaLabel:o(`settings.openchamber.visual.field.showTurnChangedFilesAria`)}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:o(`settings.openchamber.visual.field.showTurnChangedFiles`)})]}),Z(`dotfiles`)&&!k()&&(0,$.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":m,onClick:()=>O(!m),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),O(!m))},children:[(0,$.jsx)(sn,{checked:m,onChange:O,ariaLabel:o(`settings.openchamber.visual.field.showDotfilesAria`)}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:o(`settings.openchamber.visual.field.showDotfiles`)})]}),Z(`fileViewerPreview`)&&(0,$.jsxs)(`div`,{className:`group flex cursor-pointer items-center gap-2 py-0.5`,role:`button`,tabIndex:0,"aria-pressed":pt,onClick:()=>En(!pt),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),En(!pt))},children:[(0,$.jsx)(`span`,{onClick:e=>e.stopPropagation(),children:(0,$.jsx)(sn,{checked:pt,onChange:En,ariaLabel:o(`settings.openchamber.defaults.field.openFilesPreviewAria`)})}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:o(`settings.openchamber.defaults.field.openFilesPreview`)})]})]}),(Z(`persistDraft`)||!f&&Z(`inputSpellcheck`))&&(0,$.jsxs)(Dp,{isMobile:f,label:(0,$.jsx)(`span`,{"data-settings-item":`chat.composer`,children:o(`settings.openchamber.visual.section.composer`)}),children:[Z(`persistDraft`)&&(0,$.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:()=>Ve(!Be),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),Ve(!Be))},children:[(0,$.jsx)(sn,{checked:Be,onChange:Ve,ariaLabel:o(`settings.openchamber.visual.field.persistDraftMessagesAria`)}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:o(`settings.openchamber.visual.field.persistDraftMessages`)})]}),!f&&Z(`inputSpellcheck`)&&(0,$.jsxs)(`div`,{"data-settings-item":`chat.spellcheck`,className:`group flex cursor-pointer items-center gap-2 py-0.5`,role:`button`,tabIndex:0,"aria-pressed":He,onClick:()=>yn(!He),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),yn(!He))},children:[(0,$.jsx)(sn,{checked:He,onChange:yn,ariaLabel:o(`settings.openchamber.visual.field.enableSpellcheckInTextInputsAria`)}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:o(`settings.openchamber.visual.field.enableSpellcheckInTextInputs`)})]})]})]})]}),Z(`reportUsage`)&&(0,$.jsxs)(Dp,{isMobile:f,label:o(`settings.openchamber.visual.section.privacy`),children:[Z(`reportUsage`)&&(0,$.jsx)(Op,{isMobile:f,itemId:`appearance.usage-reports`,label:o(`settings.openchamber.visual.field.sendAnonymousUsageReports`),description:o(`settings.openchamber.visual.field.sendAnonymousUsageReportsHint`),children:(0,$.jsx)(sn,{checked:Wt,onChange:Kt,ariaLabel:o(`settings.openchamber.visual.field.sendAnonymousUsageReportsAria`)})}),Z(`reportUsage`)&&(0,$.jsx)(Op,{isMobile:f,itemId:`appearance.transcript-cache`,label:o(`settings.openchamber.visual.transcriptCache.label`),description:o(`settings.openchamber.visual.transcriptCache.description`),children:(0,$.jsx)(J,{type:`button`,variant:`destructive`,size:`sm`,disabled:kt,onClick:()=>Ot(!0),children:o(`settings.openchamber.visual.transcriptCache.action`)})})]})]}),(0,$.jsx)(Qt,{open:Dt,onOpenChange:e=>{kt||Ot(e)},children:(0,$.jsxs)(Yt,{className:`max-w-[min(480px,100vw-2rem)]`,children:[(0,$.jsxs)(qt,{children:[(0,$.jsx)(Xt,{children:o(`settings.openchamber.visual.transcriptCache.dialog.title`)}),(0,$.jsx)(Zt,{children:o(`settings.openchamber.visual.transcriptCache.dialog.description`)})]}),(0,$.jsxs)(Jt,{children:[(0,$.jsx)(J,{type:`button`,variant:`ghost`,disabled:kt,onClick:()=>Ot(!1),children:o(`settings.common.actions.cancel`)}),(0,$.jsx)(J,{type:`button`,variant:`destructive`,disabled:kt,"aria-busy":kt||void 0,onClick:()=>void In(),children:o(kt?`settings.openchamber.visual.transcriptCache.dialog.clearing`:`settings.openchamber.visual.transcriptCache.action`)})]})]})})]})},Kp=1,qp=365,Jp=30,Yp=[{value:`archive`,labelKey:`settings.openchamber.sessionRetention.action.archive`},{value:`delete`,labelKey:`settings.openchamber.sessionRetention.action.delete`}],Xp=()=>{let e=(0,Ii.c)(101),{t}=Me(),n=K(Zp),r=K(Qp),i=K($p),a=K(em),o=K(tm),s=K(nm),c;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(c={autoRun:!1},e[0]=c):c=e[0];let{candidates:l,isRunning:u,runCleanup:d,action:f}=ur(c),p=l.length,m;e[1]!==d||e[2]!==t?(m=async()=>{let e=await d({force:!0});if(e.completedIds.length===0&&e.failedIds.length===0){Y.message(e.action===`archive`?t(`settings.openchamber.sessionRetention.toast.noneEligibleArchive`):t(`settings.openchamber.sessionRetention.toast.noneEligibleDelete`));return}e.completedIds.length>0&&Y.success(e.action===`archive`?t(`settings.openchamber.sessionRetention.toast.archivedCount`,{count:e.completedIds.length}):t(`settings.openchamber.sessionRetention.toast.deletedCount`,{count:e.completedIds.length})),e.failedIds.length>0&&Y.error(e.action===`archive`?t(`settings.openchamber.sessionRetention.toast.failedArchiveCount`,{count:e.failedIds.length}):t(`settings.openchamber.sessionRetention.toast.failedDeleteCount`,{count:e.failedIds.length}))},e[1]=d,e[2]=t,e[3]=m):m=e[3];let h=m,g;e[4]===t?g=e[5]:(g=t(`settings.openchamber.sessionRetention.title`),e[4]=t,e[5]=g);let _;e[6]===g?_=e[7]:(_=(0,$.jsx)(`span`,{children:g}),e[6]=g,e[7]=_);let v;e[8]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(pn,{asChild:!0,children:(0,$.jsx)(X,{name:`information`,className:`h-3.5 w-3.5 cursor-help text-muted-foreground/60`})}),e[8]=v):v=e[8];let y;e[9]===t?y=e[10]:(y=t(`settings.openchamber.sessionRetention.tooltip`),e[9]=t,e[10]=y);let b;e[11]===y?b=e[12]:(b=(0,$.jsxs)(hn,{children:[v,(0,$.jsx)(mn,{sideOffset:8,className:`max-w-xs`,children:y})]}),e[11]=y,e[12]=b);let x;e[13]!==_||e[14]!==b?(x=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[_,b]}),e[13]=_,e[14]=b,e[15]=x):x=e[15];let S,C;e[16]!==n||e[17]!==a?(S=()=>a(!n),C=e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),a(!n))},e[16]=n,e[17]=a,e[18]=S,e[19]=C):(S=e[18],C=e[19]);let w;e[20]===t?w=e[21]:(w=t(`settings.openchamber.sessionRetention.field.enableAutoCleanup`),e[20]=t,e[21]=w);let T;e[22]===w?T=e[23]:(T=(0,$.jsx)(`div`,{className:`oc-settings-split-row-copy`,children:(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:w})}),e[22]=w,e[23]=T);let E;e[24]===t?E=e[25]:(E=t(`settings.openchamber.sessionRetention.field.enableAutoCleanupAria`),e[24]=t,e[25]=E);let D;e[26]!==n||e[27]!==a||e[28]!==E?(D=(0,$.jsx)(`div`,{className:`oc-settings-split-row-control`,children:(0,$.jsx)(sn,{checked:n,onChange:a,ariaLabel:E})}),e[26]=n,e[27]=a,e[28]=E,e[29]=D):D=e[29];let O;e[30]!==n||e[31]!==T||e[32]!==D||e[33]!==S||e[34]!==C?(O=(0,$.jsxs)(`div`,{"data-settings-item":`sessions.auto-cleanup`,className:`oc-settings-group-row oc-settings-split-row group cursor-pointer`,role:`button`,tabIndex:0,"aria-pressed":n,onClick:S,onKeyDown:C,children:[T,D]}),e[30]=n,e[31]=T,e[32]=D,e[33]=S,e[34]=C,e[35]=O):O=e[35];let k;e[36]===t?k=e[37]:(k=t(`settings.openchamber.sessionRetention.field.retentionPeriod`),e[36]=t,e[37]=k);let A;e[38]===t?A=e[39]:(A=t(`settings.openchamber.sessionRetention.field.retentionPeriodAria`),e[38]=t,e[39]=A);let j;e[40]!==r||e[41]!==o||e[42]!==A?(j=(0,$.jsx)(Fr,{value:r,onValueChange:o,min:Kp,max:qp,step:1,"aria-label":A,className:`w-20 tabular-nums`}),e[40]=r,e[41]=o,e[42]=A,e[43]=j):j=e[43];let M;e[44]===t?M=e[45]:(M=t(`settings.openchamber.sessionRetention.field.days`),e[44]=t,e[45]=M);let N;e[46]===M?N=e[47]:(N=(0,$.jsx)(`span`,{className:`typography-ui-label text-muted-foreground`,children:M}),e[46]=M,e[47]=N);let P;e[48]===o?P=e[49]:(P=()=>o(Jp),e[48]=o,e[49]=P);let F=r===Jp,I;e[50]===t?I=e[51]:(I=t(`settings.openchamber.sessionRetention.actions.resetRetentionAria`),e[50]=t,e[51]=I);let L;e[52]===t?L=e[53]:(L=t(`settings.common.actions.reset`),e[52]=t,e[53]=L);let R;e[54]===Symbol.for(`react.memo_cache_sentinel`)?(R=(0,$.jsx)(X,{name:`restart`,className:`h-3.5 w-3.5`}),e[54]=R):R=e[54];let z;e[55]!==P||e[56]!==F||e[57]!==I||e[58]!==L?(z=(0,$.jsx)(J,{size:`sm`,type:`button`,variant:`ghost`,onClick:P,disabled:F,className:`h-7 w-7 px-0 text-muted-foreground hover:text-foreground`,"aria-label":I,title:L,children:R}),e[55]=P,e[56]=F,e[57]=I,e[58]=L,e[59]=z):z=e[59];let B;e[60]!==k||e[61]!==j||e[62]!==N||e[63]!==z?(B=(0,$.jsxs)(Nr,{itemId:`sessions.retention-period`,label:k,children:[j,N,z]}),e[60]=k,e[61]=j,e[62]=N,e[63]=z,e[64]=B):B=e[64];let V;e[65]===t?V=e[66]:(V=t(`settings.openchamber.sessionRetention.field.whenSessionsExpire`),e[65]=t,e[66]=V);let H;e[67]!==i||e[68]!==s||e[69]!==t?(H=Yp.map(e=>(0,$.jsx)(J,{type:`button`,variant:`chip`,size:`xs`,"aria-pressed":i===e.value,className:`!font-normal`,onClick:()=>s(e.value),children:t(e.labelKey)},e.value)),e[67]=i,e[68]=s,e[69]=t,e[70]=H):H=e[70];let U;e[71]===H?U=e[72]:(U=(0,$.jsx)(`div`,{className:`flex flex-wrap items-center justify-end gap-1`,children:H}),e[71]=H,e[72]=U);let W;e[73]!==V||e[74]!==U?(W=(0,$.jsx)(Nr,{itemId:`sessions.retention-action`,label:V,children:U}),e[73]=V,e[74]=U,e[75]=W):W=e[75];let ee;e[76]!==O||e[77]!==B||e[78]!==W||e[79]!==x?(ee=(0,$.jsxs)(vi,{label:x,children:[O,B,W]}),e[76]=O,e[77]=B,e[78]=W,e[79]=x,e[80]=ee):ee=e[80];let G;e[81]===t?G=e[82]:(G=t(`settings.openchamber.sessionRetention.manualCleanup.title`),e[81]=t,e[82]=G);let te;e[83]!==f||e[84]!==p||e[85]!==t?(te=t(f===`archive`?`settings.openchamber.sessionRetention.manualCleanup.eligibleArchiveNow`:`settings.openchamber.sessionRetention.manualCleanup.eligibleDeleteNow`,{count:p}),e[83]=f,e[84]=p,e[85]=t,e[86]=te):te=e[86];let ne;e[87]!==u||e[88]!==t?(ne=t(u?`settings.openchamber.sessionRetention.actions.cleaningUp`:`settings.openchamber.sessionRetention.actions.runCleanupNow`),e[87]=u,e[88]=t,e[89]=ne):ne=e[89];let re;e[90]!==h||e[91]!==u||e[92]!==ne?(re=(0,$.jsx)(J,{type:`button`,variant:`outline`,size:`xs`,onClick:h,disabled:u,className:`!font-normal`,children:ne}),e[90]=h,e[91]=u,e[92]=ne,e[93]=re):re=e[93];let ie;e[94]!==G||e[95]!==te||e[96]!==re?(ie=(0,$.jsx)(Jr,{label:G,description:te,descriptionPlacement:`outside`,children:re}),e[94]=G,e[95]=te,e[96]=re,e[97]=ie):ie=e[97];let ae;return e[98]!==ee||e[99]!==ie?(ae=(0,$.jsxs)(`div`,{className:`oc-settings-section-stack`,children:[ee,ie]}),e[98]=ee,e[99]=ie,e[100]=ae):ae=e[100],ae};function Zp(e){return e.autoDeleteEnabled}function Qp(e){return e.autoDeleteAfterDays}function $p(e){return e.sessionRetentionAction}function em(e){return e.setAutoDeleteEnabled}function tm(e){return e.setAutoDeleteAfterDays}function nm(e){return e.setSessionRetentionAction}var rm=(e,t,n)=>!e||!Number.isFinite(e)?t:new Intl.DateTimeFormat(Pe(),{dateStyle:`medium`,timeStyle:`short`,hour12:n===`auto`?void 0:n===`12h`}).format(e),im=()=>{let{t:e}=Me(),t=K(e=>e.timeFormatPreference),[n,r]=Q.useState(!1),[i,a]=Q.useState(!0),[o,s]=Q.useState(!1),[c,l]=Q.useState(null),[u,d]=Q.useState(!1),[f,p]=Q.useState([]),[m,h]=Q.useState(gn),[g,_]=Q.useState(``),v=Q.useMemo(()=>jn(),[]),y=Q.useCallback(async()=>{a(!0),_(``);try{let e=await kn();p(e)}catch(t){let n=t instanceof Error?t.message:e(`settings.openchamber.passkeys.toast.loadFailed`);_(n)}finally{a(!1)}},[e]);Q.useEffect(()=>{let e=!1;return(async()=>{try{if(!v.supported){e||(r(!1),a(!1));return}e||r(!0)}catch{e||r(!1)}if(!e){let e=await er();if(h(e),!e.enabled){p([]),a(!1);return}await y()}})(),()=>{e=!0,nr()}},[y,v.supported]);let b=Q.useCallback(async()=>{if(!m.enabled){let t=e(`settings.openchamber.passkeys.toast.enableUiPasswordFirst`);_(t),Y.message(t);return}if(!n){_(v.reason),Y.message(v.reason);return}if(o){nr(),s(!1);return}_(``),s(!0);try{await xn(),h(await er()),await y(),Y.success(e(`settings.openchamber.passkeys.toast.added`))}catch(t){if(Nn(t)){Y.message(e(`settings.openchamber.passkeys.toast.setupCanceled`));return}let n=t instanceof Error?t.message:e(`settings.openchamber.passkeys.toast.addFailed`);_(n),Y.error(n)}finally{s(!1)}},[o,y,m.enabled,v.reason,n,e]),x=Q.useCallback(async t=>{l(t),_(``);try{await On(t),h(await er()),await y(),Y.success(e(`settings.openchamber.passkeys.toast.removed`))}catch(t){let n=t instanceof Error?t.message:e(`settings.openchamber.passkeys.toast.removeFailed`);_(n),Y.error(n)}finally{l(null)}},[y,e]),S=Q.useCallback(async()=>{d(!0),_(``);try{await wn(),window.location.reload()}catch(t){let n=t instanceof Error?t.message:e(`settings.openchamber.passkeys.toast.clearAuthFailed`);_(n),Y.error(n),d(!1)}},[e]);return(0,$.jsxs)(vi,{label:e(`settings.openchamber.passkeys.title`),children:[(0,$.jsx)(Nr,{label:e(`settings.openchamber.passkeys.field.currentDevice`),children:(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[(0,$.jsx)(J,{type:`button`,variant:o?`secondary`:`outline`,size:`xs`,onClick:()=>void b(),disabled:i||u,className:`!font-normal`,children:e(o?`settings.openchamber.passkeys.actions.cancelSetup`:`settings.openchamber.passkeys.actions.add`)}),(0,$.jsx)(J,{type:`button`,variant:`ghost`,size:`xs`,onClick:()=>void S(),disabled:i||o||u,className:`!font-normal text-muted-foreground hover:text-foreground`,children:e(u?`settings.openchamber.passkeys.actions.signingOut`:`settings.openchamber.passkeys.actions.signOutEverywhere`)})]})}),!m.enabled&&(0,$.jsx)(`p`,{className:`oc-settings-group-row typography-meta text-muted-foreground`,children:e(`settings.openchamber.passkeys.state.uiPasswordRequired`)}),m.enabled&&!n&&(0,$.jsx)(`p`,{className:`oc-settings-group-row typography-meta text-muted-foreground`,children:v.reason}),i?(0,$.jsx)(`p`,{className:`oc-settings-group-row typography-meta text-muted-foreground`,children:e(`settings.openchamber.passkeys.state.loading`)}):f.length===0?(0,$.jsx)(`p`,{className:`oc-settings-group-row typography-meta text-muted-foreground`,children:e(`settings.openchamber.passkeys.state.noneSaved`)}):(0,$.jsx)($.Fragment,{children:f.map(n=>(0,$.jsx)(Nr,{label:n.label,copyClassName:`truncate`,children:(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center justify-between gap-3`,children:[(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground truncate`,children:n.lastUsedAt?e(`settings.openchamber.passkeys.item.lastUsed`,{time:rm(n.lastUsedAt,e(`settings.openchamber.passkeys.time.neverUsed`),t)}):e(`settings.openchamber.passkeys.item.added`,{time:rm(n.createdAt,e(`settings.openchamber.passkeys.time.neverUsed`),t)})}),(0,$.jsx)(J,{type:`button`,variant:`ghost`,size:`xs`,onClick:()=>void x(n.id),disabled:c===n.id,className:`!font-normal text-muted-foreground hover:text-foreground`,children:c===n.id?e(`settings.openchamber.passkeys.actions.removing`):e(`settings.common.actions.delete`)})]})},n.id))}),g&&(0,$.jsx)(`div`,{className:`oc-settings-group-row`,children:(0,$.jsx)(`p`,{className:`typography-meta text-[var(--status-error)]`,children:g})})]})},am=e=>Ht(e)||{providerId:``,modelId:``},om=()=>{let{t:e}=Me(),t=Mt(e=>e.setProvider),n=Mt(e=>e.setModel),r=Mt(e=>e.setAgent),i=Mt(e=>e.setCurrentVariant),a=Mt(e=>e.setSettingsDefaultModel),o=Mt(e=>e.setSettingsDefaultVariant),s=Mt(e=>e.setSettingsDefaultAgent),c=K(e=>e.showDeletionDialog),u=K(e=>e.setShowDeletionDialog),d=Mt(e=>e.providers),[f,p]=Q.useState(),[m,h]=Q.useState(),[g,_]=Q.useState(),[v,y]=Q.useState(!0),b=Q.useMemo(()=>am(f),[f]);Q.useEffect(()=>{(async()=>{try{let e=null;if(!e){let t=L()?.settings;if(t)try{let n=(await t.load())?.settings;if(n){let t=n;e={defaultModel:typeof n.defaultModel==`string`?n.defaultModel:void 0,defaultVariant:typeof t.defaultVariant==`string`?t.defaultVariant:void 0,defaultAgent:typeof n.defaultAgent==`string`?n.defaultAgent:void 0}}}catch{}}if(!e){let t=await l(`/api/config/settings`,{method:`GET`,headers:{Accept:`application/json`}});t.ok&&(e=await t.json())}if(e){let t=typeof e.defaultModel==`string`&&e.defaultModel.trim().length>0?e.defaultModel.trim():void 0,n=typeof e.defaultVariant==`string`&&e.defaultVariant.trim().length>0?e.defaultVariant.trim():void 0,r=typeof e.defaultAgent==`string`&&e.defaultAgent.trim().length>0?e.defaultAgent.trim():void 0;t!==void 0&&p(t),n!==void 0&&h(n),r!==void 0&&_(r)}}catch(e){console.warn(`Failed to load defaults settings:`,e)}finally{y(!1)}})()},[]);let x=Q.useCallback(async(e,r)=>{let s=e&&r?`${e}/${r}`:void 0;p(s),h(void 0),o(void 0),i(void 0),a(s),e&&r&&d.find(t=>t.id===e)&&(t(e),n(r));try{await M({defaultModel:s??``,defaultVariant:``});let e=await l(`/api/config/settings`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({defaultModel:s})});e.ok||console.warn(`Failed to save default model to server:`,e.status,e.statusText)}catch(e){console.warn(`Failed to save default model:`,e)}},[d,i,n,t,a,o]),S=`__default__`,C=Q.useCallback(t=>t===S?e(`settings.openchamber.defaults.option.default`):t.charAt(0).toUpperCase()+t.slice(1),[e]),w=Q.useCallback(async e=>{let t=e===S?void 0:e||void 0;h(t),o(t),i(t);try{await M({defaultVariant:t??``})}catch(e){console.warn(`Failed to save default variant:`,e)}},[i,o]),T=Q.useCallback(async e=>{let t=e||void 0;_(t),s(t),e&&r(e);try{await M({defaultAgent:t??``})}catch(e){console.warn(`Failed to save default agent:`,e)}},[r,s]),E=Q.useMemo(()=>{if(!b.providerId||!b.modelId)return[];let e=d.find(e=>e.id===b.providerId)?.models.find(e=>e.id===b.modelId)?.variants;return e?Object.keys(e):[]},[b.modelId,b.providerId,d]),D=E.length>0;return Q.useEffect(()=>{!D&&m&&(h(void 0),o(void 0),i(void 0),M({defaultVariant:``}).catch(()=>{}))},[m,i,o,D]),v?null:(0,$.jsxs)(vi,{label:e(`settings.openchamber.defaults.title`),description:(0,$.jsxs)($.Fragment,{children:[e(`settings.openchamber.defaults.summaryPrefix`),` `,b.providerId?(0,$.jsxs)(`span`,{className:`text-foreground`,children:[b.providerId,`/`,b.modelId,D?` (${m??e(`settings.openchamber.defaults.option.defaultLowercase`)})`:``]}):(0,$.jsx)(`span`,{className:`text-foreground`,children:e(`settings.openchamber.defaults.summaryOpenCodeDefault`)}),g&&(0,$.jsxs)($.Fragment,{children:[` / `,(0,$.jsx)(`span`,{className:`text-foreground`,children:g})]})]}),children:[(0,$.jsx)(Nr,{itemId:`sessions.default-model`,label:e(`settings.openchamber.defaults.field.defaultModel`),children:(0,$.jsx)(Tn,{providerId:b.providerId,modelId:b.modelId,onChange:x,className:`oc-settings-inline-value`})}),(0,$.jsx)(Nr,{itemId:`sessions.default-thinking`,label:e(`settings.openchamber.defaults.field.defaultThinking`),children:(0,$.jsxs)(ln,{value:m??S,onValueChange:w,disabled:!D,children:[(0,$.jsx)(rn,{className:`w-fit min-w-[120px]`,children:(0,$.jsx)(dn,{placeholder:e(`settings.openchamber.defaults.field.thinkingPlaceholder`),children:C(m??S)})}),(0,$.jsxs)(an,{children:[(0,$.jsx)(tn,{value:S,children:e(`settings.openchamber.defaults.option.default`)}),E.map(e=>(0,$.jsx)(tn,{value:e,children:C(e)},e))]})]})}),(0,$.jsx)(Nr,{itemId:`sessions.default-agent`,label:e(`settings.openchamber.defaults.field.defaultAgent`),children:(0,$.jsx)(fr,{agentName:g||``,onChange:T,className:`oc-settings-inline-value`})}),(0,$.jsxs)(`div`,{"data-settings-item":`sessions.deletion-dialog`,className:`oc-settings-group-row oc-settings-split-row group cursor-pointer`,role:`button`,tabIndex:0,"aria-pressed":c,onClick:()=>u(!c),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),u(!c))},children:[(0,$.jsx)(`div`,{className:`oc-settings-split-row-copy`,children:(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:e(`settings.openchamber.defaults.field.showDeletionDialog`)})}),(0,$.jsx)(`div`,{className:`oc-settings-split-row-control`,children:(0,$.jsx)(sn,{checked:c,onChange:u,ariaLabel:e(`settings.openchamber.defaults.field.showDeletionDialogAria`)})})]})]})},sm=`You are generating a Conventional Commits subject line from the diffs of the selected files.`,cm=[`You are a title generator. Output ONLY a thread title.`,`Name the main subject of the work.`,`Keep that subject across follow-ups, polish, commit, push, tidy, and review.`,`Switch only when the user clearly starts a different topic.`,`One line, no explanation.`,`Hard limit: never exceed 6 CJK characters (or 6 words for English). No modifiers. No verbs.`,`Use the language of the user messages.`,`Keep technical terms, numbers, filenames, and HTTP codes exact.`,`Never include tool names, summarizing, or generating.`,`Always output a meaningful title.`].join(`
|
|
25
|
+
`),lm=`summary-custom-model-suggestions`,um=e=>{let t=e.trim();if(!t)return null;try{let e=new URL(t);return e.protocol!==`https:`&&e.protocol!==`http:`||e.username||e.password?null:e.toString().replace(/\/+$/,``)}catch{return null}},dm=()=>{let{t:e}=Me(),{currentTheme:t}=vr(),[n,r]=Q.useState(`provider`),[i,a]=Q.useState(``),[o,s]=Q.useState(``),[c,u]=Q.useState(``),[d,f]=Q.useState(``),[p,m]=Q.useState(``),[h,g]=Q.useState(!1),[_,v]=Q.useState(sm),[y,b]=Q.useState(cm),[x,S]=Q.useState([]),[C,w]=Q.useState(!0),[T,E]=Q.useState(!1),[D,O]=Q.useState(!1),k=Q.useMemo(()=>[Gr(t,{syntaxColors:!1})],[t]);Q.useEffect(()=>{let e=!0;return(async()=>{try{let t=null,n=L()?.settings;if(n){let e=(await n.load())?.settings;e&&(t=e)}if(!t){let e=await l(`/api/config/settings`,{method:`GET`,headers:{Accept:`application/json`}});e.ok&&(t=await e.json())}if(!e||!t)return;t.summaryModelMode&&r(t.summaryModelMode),typeof t.summaryProviderID==`string`&&a(t.summaryProviderID),typeof t.summaryModelID==`string`&&s(t.summaryModelID),typeof t.summaryCustomModelID==`string`&&t.summaryCustomModelID?u(t.summaryCustomModelID):t.summaryModelMode===`custom`&&typeof t.summaryModelID==`string`&&u(t.summaryModelID),typeof t.summaryCustomBaseURL==`string`&&f(t.summaryCustomBaseURL),typeof t.hasSummaryCustomAPIToken==`boolean`&&g(t.hasSummaryCustomAPIToken),v(t.summaryCommitPrompt??sm),b(t.summarySessionTitlePrompt??cm)}catch(e){console.warn(`Failed to load summary settings:`,e)}finally{e&&w(!1)}})(),()=>{e=!1}},[]),Q.useEffect(()=>{if(n!==`custom`){S([]);return}let e=um(d);if(!e||!p.trim()&&!h){S([]);return}let t=!0,r=window.setTimeout(()=>{(async()=>{try{let n=await(await l(`/api/small-model/custom-models`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`},body:JSON.stringify({baseURL:e,...p.trim()?{apiToken:p}:{}})})).json().catch(()=>null),r=Array.isArray(n?.models)?n.models.filter(e=>typeof e==`string`&&e.length>0):[];t&&S(r)}catch{t&&S([])}})()},400);return()=>{t=!1,window.clearTimeout(r)}},[h,p,d,n]);let A=()=>um(d)?!c.trim()||!p.trim()&&!h?`incomplete`:null:d.trim()?`baseURL`:`incomplete`,j=t=>{t===`token`?Y.error(e(`settings.openchamber.defaults.summary.testError.token`)):t===`model`?Y.error(e(`settings.openchamber.defaults.summary.testError.model`)):t===`baseURL`?Y.error(e(`settings.openchamber.defaults.summary.testError.baseUrl`)):Y.error(e(`settings.openchamber.defaults.summary.testError.incomplete`))},N=Ae(async()=>{if(n===`custom`){let e=A();if(e){j(e);return}}E(!0);try{let e={summaryModelMode:n,summaryCommitPrompt:_,summarySessionTitlePrompt:y};n===`provider`?(e.summaryProviderID=i.trim(),e.summaryModelID=o.trim()):(e.summaryCustomBaseURL=d,e.summaryCustomModelID=c.trim(),p.trim()&&(e.summaryCustomAPIToken=p)),await M(e),p.trim()&&g(!0),m(``)}catch(e){console.warn(`Failed to save summary settings:`,e)}finally{E(!1)}}),P=Ae(async()=>{E(!0);try{await M({summaryCustomAPIToken:``}),m(``),g(!1)}catch(e){console.warn(`Failed to clear summary API token:`,e)}finally{E(!1)}}),F=Ae(async()=>{let t=A();if(t){j(t);return}O(!0);try{let t=await(await l(`/api/small-model/test`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`},body:JSON.stringify({baseURL:d,modelID:c,...p.trim()?{apiToken:p}:{}})})).json().catch(()=>null);if(t?.ok===!0){Y.success(e(`settings.openchamber.defaults.summary.testConnectionOk`));return}let n=t?.code===`token`||t?.code===`model`||t?.code===`baseURL`||t?.code===`incomplete`?t.code:`baseURL`;j(n)}catch{j(`baseURL`)}finally{O(!1)}});return C?null:(0,$.jsxs)(`div`,{className:`oc-settings-section-stack`,children:[(0,$.jsxs)(vi,{label:e(`settings.openchamber.defaults.summary.title`),description:e(`settings.openchamber.defaults.summary.description`),children:[(0,$.jsx)(Nr,{itemId:`summary-ai.configuration`,label:e(`settings.openchamber.defaults.summary.modelSourceTitle`),className:`oc-settings-summary-model-source-row`,controlClassName:`items-start`,children:(0,$.jsxs)(`div`,{role:`radiogroup`,"aria-label":e(`settings.openchamber.defaults.summary.modelSourceAria`),className:`flex flex-col gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-2 py-0.5`,children:[(0,$.jsx)(Ks,{checked:n===`provider`,onChange:()=>r(`provider`),ariaLabel:e(`settings.openchamber.defaults.summary.provider`)}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:n===`provider`?`typography-ui-label text-foreground`:`typography-ui-label text-foreground/50`,children:e(`settings.openchamber.defaults.summary.provider`)}),(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground`,children:e(`settings.openchamber.defaults.summary.providerDescription`)})]})]}),(0,$.jsxs)(`div`,{className:`flex items-start gap-2 py-0.5`,children:[(0,$.jsx)(Ks,{checked:n===`custom`,onChange:()=>r(`custom`),ariaLabel:e(`settings.openchamber.defaults.summary.custom`)}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:n===`custom`?`typography-ui-label text-foreground`:`typography-ui-label text-foreground/50`,children:e(`settings.openchamber.defaults.summary.custom`)}),(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground`,children:e(`settings.openchamber.defaults.summary.customDescription`)})]})]})]})}),n===`provider`?(0,$.jsx)(Nr,{label:e(`settings.openchamber.defaults.summary.providerModel`),children:(0,$.jsx)(Tn,{providerId:i,modelId:o,placeholder:e(`settings.openchamber.defaults.summary.providerModelDefault`),onChange:(e,t)=>{a(e),s(t)},className:`oc-settings-inline-value`})}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Nr,{label:e(`settings.openchamber.defaults.summary.baseUrl`),children:(0,$.jsx)(fn,{value:d,onChange:e=>f(e.target.value),placeholder:e(`settings.openchamber.defaults.summary.baseUrlPlaceholder`)})}),(0,$.jsx)(Nr,{label:e(`settings.openchamber.defaults.summary.modelId`),children:(0,$.jsxs)(`div`,{className:`w-full`,children:[(0,$.jsx)(fn,{value:c,onChange:e=>u(e.target.value),placeholder:e(`settings.openchamber.defaults.summary.modelIdPlaceholder`),list:x.length>0?lm:void 0}),x.length>0?(0,$.jsx)(`datalist`,{id:lm,children:x.map(e=>(0,$.jsx)(`option`,{value:e},e))}):null]})}),(0,$.jsx)(Nr,{label:e(`settings.openchamber.defaults.summary.apiToken`),children:(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(fn,{type:`password`,value:p,onChange:e=>m(e.target.value),placeholder:e(h?`settings.openchamber.defaults.summary.apiTokenStored`:`settings.openchamber.defaults.summary.apiTokenPlaceholder`),className:`max-w-xl`}),h?(0,$.jsx)(J,{variant:`outline`,size:`sm`,onClick:()=>void P(),disabled:T,children:e(`settings.openchamber.defaults.summary.clearToken`)}):null]})}),(0,$.jsx)(Nr,{label:e(`settings.openchamber.defaults.summary.testConnection`),children:(0,$.jsx)(J,{variant:`outline`,size:`sm`,onClick:()=>void F(),disabled:T||D,children:e(D?`settings.openchamber.defaults.summary.testingConnection`:`settings.openchamber.defaults.summary.testConnection`)})})]})]}),(0,$.jsxs)(vi,{label:e(`settings.openchamber.defaults.summary.promptTitle`),children:[(0,$.jsx)(Nr,{label:e(`settings.openchamber.defaults.summary.commitPrompt`),description:e(`settings.openchamber.defaults.summary.commitPromptDescription`),className:`oc-settings-split-row-stacked`,controlClassName:`w-full max-w-none justify-self-stretch`,children:(0,$.jsx)(`div`,{className:`h-64 w-full overflow-hidden bg-background`,children:(0,$.jsx)(qr,{value:_,onChange:v,extensions:k,className:`h-full`,enableSearch:!0})})}),(0,$.jsx)(Nr,{label:e(`settings.openchamber.defaults.summary.sessionTitlePrompt`),description:e(`settings.openchamber.defaults.summary.sessionTitlePromptDescription`),className:`oc-settings-split-row-stacked`,controlClassName:`w-full max-w-none justify-self-stretch`,children:(0,$.jsx)(`div`,{className:`h-64 w-full overflow-hidden bg-background`,children:(0,$.jsx)(qr,{value:y,onChange:b,extensions:k,className:`h-full`,enableSearch:!0})})}),(0,$.jsx)(`div`,{className:`oc-settings-group-row flex items-center justify-end`,children:(0,$.jsx)(J,{size:`sm`,onClick:()=>void N(),disabled:T,children:e(T?`settings.common.actions.saving`:`settings.openchamber.defaults.summary.save`)})})]})]})},fm={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`}},pm={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`},mm=()=>{let{t:e}=Me(),t=Q.useMemo(()=>u(),[]),n=Q.useMemo(()=>k(),[]),r=Q.useMemo(()=>typeof window>`u`?!1:window.Capacitor?.isNativePlatform?.()===!0||window.location.protocol===`capacitor:`,[]),i=!t&&!n&&!r,a=K(e=>e.nativeNotificationsEnabled),o=K(e=>e.setNativeNotificationsEnabled),s=K(e=>e.notificationMode),c=K(e=>e.setNotificationMode),l=K(e=>e.notifyOnSubtasks),d=K(e=>e.setNotifyOnSubtasks),f=K(e=>e.notifyOnCompletion),p=K(e=>e.setNotifyOnCompletion),m=K(e=>e.notifyOnError),h=K(e=>e.setNotifyOnError),g=K(e=>e.notifyOnQuestion),_=K(e=>e.setNotifyOnQuestion),v=K(e=>e.notifyOnPermission),y=K(e=>e.setNotifyOnPermission),b=K(e=>e.notifyOnScheduledTasks),x=K(e=>e.setNotifyOnScheduledTasks),S=K(e=>e.notifyOnAssistants),C=K(e=>e.setNotifyOnAssistants),w=K(e=>e.notifyOnGoals),T=K(e=>e.setNotifyOnGoals),E=K(e=>e.notificationTemplates),D=K(e=>e.setNotificationTemplates),[O,A]=Q.useState(`default`),[j,M]=Q.useState(!1),[N,P]=Q.useState(!1),[F,I]=Q.useState(!1);Q.useEffect(()=>{if(!i){M(!1),P(!1);return}typeof Notification<`u`&&A(Notification.permission);let e=typeof window<`u`&&`serviceWorker`in navigator&&`PushManager`in window&&`Notification`in window;M(e),(async()=>{if(!e){P(!1);return}try{let e=await navigator.serviceWorker.getRegistration();if(!e){P(!1);return}let t=await e.pushManager.getSubscription();P(!!t)}catch{P(!1)}})()},[i]);let R=async n=>{if(t){o(n);return}if(!i){o(n);return}if(n&&typeof Notification<`u`&&Notification.permission==="default")try{let t=await Notification.requestPermission();A(t),t===`granted`?o(!0):Y.error(e(`settings.notifications.page.toast.permissionDenied.title`),{description:e(`settings.notifications.page.toast.permissionDenied.description`)})}catch(t){console.error(`Failed to request notification permission:`,t),Y.error(e(`settings.notifications.page.toast.requestPermissionFailed`))}else o(!!(n&&O===`granted`))},z=t||n||r||i&&typeof Notification<`u`&&Notification.permission===`granted`,B=(e,t,n)=>{D({...E,[e]:{...E[e],[t]:n}})},V=e=>{let t=(e+`=`.repeat((4-e.length%4)%4)).replace(/-/g,`+`).replace(/_/g,`/`),n=atob(t),r=new Uint8Array(n.length);for(let e=0;e<n.length;e+=1)r[e]=n.charCodeAt(e);return r},H=async(e,t,n)=>{let r=null,i=new Promise((e,i)=>{r=setTimeout(()=>{i(Error(n))},t)});try{return await Promise.race([e,i])}finally{r&&clearTimeout(r)}},U=async e=>{if(e.active)return;let t=e.installing||e.waiting;t&&t.state!==`activated`&&await H(new Promise(e=>{let n=()=>{t.state===`activated`&&(t.removeEventListener(`statechange`,n),e())};t.addEventListener(`statechange`,n),n()}),15e3,`Service worker activation timed out`)},W=async()=>{if(typeof navigator.serviceWorker.register!=`function`)throw Error(`navigator.serviceWorker.register unavailable`);let e=[{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:`/`}}],t=null;for(let n of e)try{let e=n.opts?navigator.serviceWorker.register(`/sw.js`,n.opts):navigator.serviceWorker.register(`/sw.js`);return await H(e,1e4,`Service worker registration timed out (${n.label})`)}catch(e){t=e}throw t instanceof Error?t:Error(`Service worker registration failed`)},ee=async()=>{if(!(`serviceWorker`in navigator))throw Error(`Service worker not supported`);let e=await navigator.serviceWorker.getRegistration();if(e)return e;let t=await W();try{await t.update()}catch{}return await U(t),t},G=e=>{let t=e,n=[`type=${typeof e}`,`toString=${String(e)}`,`name=${String(t?.name??``)}`,`message=${String(t?.message??``)}`],r=``;try{r=JSON.stringify(e)}catch{}return{summary:n.filter(Boolean).join(` | `),json:r,stack:typeof t?.stack==`string`?t.stack:``}},te=async()=>{let t=L();if(!t?.notifications){Y.error(e(`settings.notifications.page.toast.notificationsApiUnavailable`));return}try{await t.notifications.notifyAgentCompletion({title:e(`settings.notifications.page.testNotification.title`),body:e(`settings.notifications.page.testNotification.body`),tag:`openchamber-test`})?Y.success(e(`settings.notifications.page.toast.testNotificationSent`)):Y.error(e(`settings.notifications.page.toast.testNotificationFailed`))}catch(t){console.error(`Test notification failed:`,t),Y.error(e(`settings.notifications.page.toast.testNotificationFailed`))}},ne=async()=>{if(!j){Y.error(e(`settings.notifications.page.toast.pushUnsupported`));return}let t=L();if(!t?.push){Y.error(e(`settings.notifications.page.toast.pushApiUnavailable`));return}I(!0);try{if(typeof Notification<`u`&&Notification.permission==="default"){let t=await Notification.requestPermission();if(A(t),t!==`granted`){Y.error(e(`settings.notifications.page.toast.permissionDenied.title`),{description:e(`settings.notifications.page.toast.permissionDenied.enableInBrowser`)});return}}if(typeof Notification<`u`&&Notification.permission!==`granted`){Y.error(e(`settings.notifications.page.toast.permissionDenied.title`),{description:e(`settings.notifications.page.toast.permissionDenied.enableInBrowser`)});return}let n=await t.push.getVapidPublicKey();if(!n?.publicKey){Y.error(e(`settings.notifications.page.toast.pushKeyLoadFailed`));return}let r=await ee();await U(r);let i=await r.pushManager.getSubscription();if(!(`pushManager`in r)||!r.pushManager)throw Error(`PushManager unavailable (requires installed PWA + iOS 16.4+)`);let a=(i??await H(r.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:V(n.publicKey)}),15e3,`Push subscription timed out`)).toJSON(),o=a.keys;if(!a.endpoint||!o?.p256dh||!o.auth)throw Error(`Push subscription missing keys`);if(!(await H(t.push.subscribe({endpoint:a.endpoint,keys:{p256dh:o.p256dh,auth:o.auth},origin:typeof window<`u`?window.location.origin:void 0,platform:he()}),15e3,`Push subscribe request timed out`))?.ok){Y.error(e(`settings.notifications.page.toast.enableBackgroundFailed`));return}P(!0),Y.success(e(`settings.notifications.page.toast.backgroundEnabled`))}catch(t){console.error(`[Push] Enable failed:`,t);let n=G(t);Y.error(e(`settings.notifications.page.toast.enableBackgroundFailed`),{description:n.summary})}finally{I(!1)}},re=async()=>{if(!j){P(!1);return}let t=L();if(!t?.push){Y.error(e(`settings.notifications.page.toast.pushApiUnavailable`));return}I(!0);try{let n=await(await ee()).pushManager.getSubscription();if(!n){P(!1);return}let r=n.endpoint;await n.unsubscribe(),await t.push.unsubscribe({endpoint:r}),P(!1),Y.success(e(`settings.notifications.page.toast.backgroundDisabled`))}finally{I(!1)}},ie=i?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`block`,children:e(`settings.notifications.page.delivery.browserPermissionHint`)}),O===`denied`?(0,$.jsx)(`span`,{className:`mt-1 block text-[var(--status-error)]`,children:e(`settings.notifications.page.delivery.permissionDenied`)}):null,O===`granted`&&!a?(0,$.jsx)(`span`,{className:`mt-1 block`,children:e(`settings.notifications.page.delivery.permissionGrantedButDisabled`)}):null]}):n?e(`settings.notifications.page.delivery.vscodeHint`):void 0;return(0,$.jsxs)(`div`,{className:`oc-settings-section-stack`,children:[(0,$.jsxs)(vi,{label:e(`settings.notifications.page.delivery.title`),description:ie,className:`oc-settings-detail-group`,children:[(0,$.jsx)(Qr,{itemId:`notifications.delivery`,checked:a&&z,onChange:e=>{R(e)},label:e(`settings.notifications.page.delivery.enableLabel`),ariaLabel:e(`settings.notifications.page.delivery.enableAria`)}),a&&z&&!r?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Qr,{checked:s===`always`,onChange:e=>c(e?`always`:`hidden-only`),label:e(`settings.notifications.page.delivery.focusedLabel`),ariaLabel:e(`settings.notifications.page.delivery.focusedAria`)}),(0,$.jsx)(`div`,{className:`oc-settings-group-row flex items-center`,children:(0,$.jsx)(J,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>void te(),children:e(`settings.notifications.page.delivery.testAction`)})})]}):null]}),a&&z?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(vi,{label:e(`settings.notifications.page.events.title`),className:`oc-settings-detail-group`,children:[(0,$.jsx)(Qr,{itemId:`notifications.events`,checked:f,onChange:p,label:e(`settings.notifications.page.events.completionLabel`),ariaLabel:e(`settings.notifications.page.events.completionAria`)}),(0,$.jsx)(Qr,{checked:l,onChange:d,label:e(`settings.notifications.page.events.subtaskLabel`),ariaLabel:e(`settings.notifications.page.events.subtaskAria`)}),(0,$.jsx)(Qr,{checked:m,onChange:h,label:e(`settings.notifications.page.events.errorLabel`),ariaLabel:e(`settings.notifications.page.events.errorAria`)}),(0,$.jsx)(Qr,{checked:g,onChange:_,label:e(`settings.notifications.page.events.questionLabel`),ariaLabel:e(`settings.notifications.page.events.questionAria`)}),(0,$.jsx)(Qr,{checked:v,onChange:y,label:e(`settings.notifications.page.events.permissionLabel`),ariaLabel:e(`settings.notifications.page.events.permissionAria`)}),(0,$.jsx)(Qr,{checked:b,onChange:x,label:e(`settings.notifications.page.events.scheduledTasksLabel`),ariaLabel:e(`settings.notifications.page.events.scheduledTasksAria`)}),(0,$.jsx)(Qr,{checked:S,onChange:C,label:e(`settings.notifications.page.events.assistantsLabel`),ariaLabel:e(`settings.notifications.page.events.assistantsAria`)}),(0,$.jsx)(Qr,{checked:w,onChange:T,label:e(`settings.notifications.page.events.goalsLabel`),ariaLabel:e(`settings.notifications.page.events.goalsAria`)})]}),r?null:(0,$.jsx)(vi,{label:e(`settings.notifications.page.template.title`),description:(0,$.jsxs)($.Fragment,{children:[e(`settings.notifications.page.template.variablesLabel`),` `,(0,$.jsx)(`code`,{className:`text-[var(--primary-base)]`,children:`{project_name}`}),` `,(0,$.jsx)(`code`,{className:`text-[var(--primary-base)]`,children:`{worktree}`}),` `,(0,$.jsx)(`code`,{className:`text-[var(--primary-base)]`,children:`{branch}`}),` `,(0,$.jsx)(`code`,{className:`text-[var(--primary-base)]`,children:`{session_name}`}),` `,(0,$.jsx)(`code`,{className:`text-[var(--primary-base)]`,children:`{agent_name}`}),` `,(0,$.jsx)(`code`,{className:`text-[var(--primary-base)]`,children:`{model_name}`}),` `,(0,$.jsx)(`code`,{className:`text-[var(--primary-base)]`,children:`{last_message}`})]}),className:`oc-settings-detail-group`,children:[`completion`,`subtask`,`error`,`question`].map(t=>(0,$.jsxs)(`div`,{className:`oc-settings-group-row`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label block font-normal text-foreground`,children:e(pm[t])}),(0,$.jsxs)(`div`,{className:`mt-2 grid grid-cols-1 gap-2 md:grid-cols-2 md:gap-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`label`,{className:`typography-micro mb-1 block text-muted-foreground`,children:e(`settings.notifications.page.template.field.title`)}),(0,$.jsx)(fn,{value:E[t].title,onChange:e=>B(t,`title`,e.target.value),className:`w-full`,placeholder:e(fm[t].titleKey)})]}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`label`,{className:`typography-micro mb-1 block text-muted-foreground`,children:e(`settings.notifications.page.template.field.message`)}),(0,$.jsx)(fn,{value:E[t].message,onChange:e=>B(t,`message`,e.target.value),className:`w-full`,placeholder:e(fm[t].messageKey)})]})]})]},t))})]}):null,i?(0,$.jsx)(vi,{label:e(`settings.notifications.page.push.title`),className:`oc-settings-detail-group`,children:(0,$.jsxs)(`div`,{"data-settings-item":`notifications.push`,className:`oc-settings-group-row flex items-center gap-2`,children:[(0,$.jsx)(sn,{checked:j?N:!1,disabled:!j||F,onChange:e=>{e?ne():re()},ariaLabel:e(`settings.notifications.page.push.enableAria`)}),(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[(0,$.jsx)(`span`,{className:q(`typography-ui-label`,j?`text-foreground`:`text-muted-foreground`),children:e(`settings.notifications.page.push.enableLabel`)}),(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:e(j?`settings.notifications.page.push.supportedHint`:`settings.notifications.page.push.unsupportedHint`)})]}),F&&(0,$.jsx)(`div`,{className:`pt-0.5 text-muted-foreground`,children:(0,$.jsx)(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full bg-current animate-busy-pulse`,"aria-label":e(`settings.notifications.page.push.loadingAria`)})})]})}):null]})},hm=e=>{if(!e)return;e.pause();let{src:t}=e;t.startsWith(`blob:`)&&URL.revokeObjectURL(t),e.removeAttribute(`src`),e.load()},gm=[{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`}],_m=e=>{let t=(0,Ii.c)(8),{value:n,label:r}=e,i=`${r}: ${n}/5`,a=`${n/5*100}%`,o;t[0]===a?o=t[1]:(o=(0,$.jsx)(`span`,{className:`h-1.5 w-12 flex-shrink-0 overflow-hidden rounded-full bg-[var(--interactive-border)]`,"aria-hidden":`true`,children:(0,$.jsx)(`span`,{className:`block h-full rounded-full bg-[var(--primary-base)]`,style:{width:a}})}),t[0]=a,t[1]=o);let s;t[2]===r?s=t[3]:(s=(0,$.jsx)(`span`,{className:`typography-ui-compact text-muted-foreground`,children:r}),t[2]=r,t[3]=s);let c;return t[4]!==i||t[5]!==o||t[6]!==s?(c=(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,title:i,children:[o,s]}),t[4]=i,t[5]=o,t[6]=s,t[7]=c):c=t[7],c},vm=({selectedModelId:e,onSelect:t})=>{let{t:n}=Me(),r=(0,Q.useCallback)(e=>n(e),[n]),[i,a]=(0,Q.useState)(new Map),[o,s]=(0,Q.useState)(null),c=(0,Q.useCallback)(async()=>{try{let e=await l(`/api/dictation/status`,{query:{provider:`local`}});if(!e.ok)return;let t=await e.json();Array.isArray(t?.models)&&a(new Map(t.models.map(e=>[e.id,e])))}catch{}},[]);(0,Q.useEffect)(()=>{c()},[c]);let u=Array.from(i.values()).some(e=>e.downloading);(0,Q.useEffect)(()=>{if(!u)return;let e=setInterval(()=>{c()},2e3);return()=>clearInterval(e)},[u,c]);let d=async e=>{s(e);try{await l(`/api/dictation/models/${encodeURIComponent(e)}/download`,{method:`POST`}),await c()}catch{}finally{s(null)}},f=async e=>{s(e);try{await l(`/api/dictation/models/${encodeURIComponent(e)}`,{method:`DELETE`}),await c()}catch{}finally{s(null)}};return(0,$.jsx)(`div`,{role:`radiogroup`,"aria-label":n(`settings.voice.page.field.model`),className:`mt-1 w-full min-w-0 space-y-0`,children:gm.map(a=>{let s=e===a.id,c=i.get(a.id)??null;return(0,$.jsxs)(`div`,{className:`flex w-full items-start gap-2 py-1.5`,children:[(0,$.jsx)(`div`,{className:`pt-0.5`,children:(0,$.jsx)(Ks,{checked:s,onChange:()=>t(a.id),ariaLabel:r(a.labelKey)})}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 cursor-pointer`,role:`button`,tabIndex:0,onClick:()=>t(a.id),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),t(a.id))},children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-0.5`,children:[(0,$.jsx)(`span`,{className:q(`typography-ui-label font-normal`,s?`text-foreground`:`text-foreground/50`),children:r(a.labelKey)}),a.badgeKey?(0,$.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:r(a.badgeKey)}):null]}),(0,$.jsxs)(`div`,{className:`mt-0.5 flex flex-wrap items-center gap-x-4 gap-y-0.5`,children:[(0,$.jsx)(_m,{value:a.accuracy,label:n(`settings.voice.page.stt.meta.accuracy`)}),(0,$.jsx)(_m,{value:a.speed,label:n(`settings.voice.page.stt.meta.speed`)}),(0,$.jsx)(`span`,{className:`typography-ui-compact tabular-nums text-muted-foreground`,children:a.size})]}),c?.downloadError?(0,$.jsx)(`p`,{className:`mt-0.5 typography-meta text-[var(--status-error)]`,children:c.downloadError}):null]}),(0,$.jsx)(`div`,{className:`flex w-14 flex-shrink-0 items-center justify-end gap-1 pt-0.5`,children:c?.installed?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(J,{variant:`ghost`,size:`xs`,className:`h-6 w-6 p-0 text-muted-foreground hover:text-[var(--status-error)]`,disabled:o===a.id,onClick:()=>{f(a.id)},title:n(`settings.voice.page.stt.modelDelete`),"aria-label":n(`settings.voice.page.stt.modelDelete`),children:(0,$.jsx)(X,{name:`delete-bin`,className:`h-4 w-4`})}),(0,$.jsx)(X,{name:`checkbox-circle`,className:`h-4 w-4 flex-shrink-0 text-[var(--status-success)]`,"aria-label":n(`settings.voice.page.stt.modelInstalled`)})]}):c?.downloading?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(X,{name:`loader-4`,className:`h-3.5 w-3.5 animate-spin text-muted-foreground`}),(0,$.jsx)(`span`,{className:`typography-ui-compact tabular-nums text-muted-foreground`,children:typeof c.downloadProgress==`number`?`${c.downloadProgress}%`:``})]}):(0,$.jsx)(J,{variant:`ghost`,size:`xs`,className:`h-6 w-6 p-0`,disabled:o===a.id,onClick:()=>{d(a.id)},title:n(`settings.voice.page.stt.modelDownload`),"aria-label":n(`settings.voice.page.stt.modelDownload`),children:(0,$.jsx)(X,{name:`download`,className:`h-4 w-4`})})})]},a.id)})})},ym=[{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)`}],bm=`kokoro-en-v0_19`,xm=()=>{let{t:e}=Me(),[t,n]=(0,Q.useState)(null),[r,i]=(0,Q.useState)(!1),a=(0,Q.useCallback)(async()=>{try{let e=await l(`/api/dictation/status`,{query:{provider:`local`}});if(!e.ok)return;let t=await e.json(),r=Array.isArray(t?.ttsModels)?t.ttsModels.find(e=>e.id===bm):null;r&&n(r)}catch{}},[]);(0,Q.useEffect)(()=>{a()},[a]),(0,Q.useEffect)(()=>{if(!t?.downloading)return;let e=setInterval(()=>{a()},2e3);return()=>clearInterval(e)},[t?.downloading,a]);let o=async e=>{i(!0);try{await l(e===`POST`?`/api/dictation/models/${bm}/download`:`/api/dictation/models/${bm}`,{method:e}),await a()}catch{}finally{i(!1)}};return t?(0,$.jsxs)(`div`,{className:`flex items-center gap-2 py-1.5`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:`Kokoro`}),(0,$.jsx)(`span`,{className:`typography-ui-compact tabular-nums text-muted-foreground`,children:`305 MB`}),t.installed?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(X,{name:`checkbox-circle`,className:`h-4 w-4 text-[var(--status-success)]`,"aria-label":e(`settings.voice.page.stt.modelInstalled`)}),(0,$.jsx)(J,{variant:`ghost`,size:`xs`,className:`h-6 w-6 p-0 text-muted-foreground hover:text-[var(--status-error)]`,disabled:r,onClick:()=>{o(`DELETE`)},title:e(`settings.voice.page.stt.modelDelete`),"aria-label":e(`settings.voice.page.stt.modelDelete`),children:(0,$.jsx)(X,{name:`delete-bin`,className:`h-4 w-4`})})]}):t.downloading?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(X,{name:`loader-4`,className:`h-3.5 w-3.5 animate-spin text-muted-foreground`}),(0,$.jsx)(`span`,{className:`typography-ui-compact tabular-nums text-muted-foreground`,children:typeof t.downloadProgress==`number`?`${t.downloadProgress}%`:``})]}):(0,$.jsx)(J,{variant:`ghost`,size:`xs`,className:`h-6 w-6 p-0`,disabled:r,onClick:()=>{o(`POST`)},title:e(`settings.voice.page.stt.modelDownload`),"aria-label":e(`settings.voice.page.stt.modelDownload`),children:(0,$.jsx)(X,{name:`download`,className:`h-4 w-4`})}),t.downloadError?(0,$.jsx)(`span`,{className:`typography-meta text-[var(--status-error)]`,children:t.downloadError}):null]}):null},Sm=[{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`}],Cm=()=>{let{t:e}=Me(),{isMobile:t}=yr(),n=Mt(e=>e.voiceProvider),r=Mt(e=>e.setVoiceProvider),i=Mt(e=>e.speechRate),a=Mt(e=>e.setSpeechRate),o=Mt(e=>e.speechPitch),s=Mt(e=>e.setSpeechPitch),c=Mt(e=>e.speechVolume),u=Mt(e=>e.setSpeechVolume),d=Mt(e=>e.sayVoice),f=Mt(e=>e.setSayVoice),p=Mt(e=>e.localTtsVoiceId),m=Mt(e=>e.setLocalTtsVoiceId),{speak:h,stop:g,isPlaying:_,error:v}=Dn(),y=(0,Q.useCallback)(()=>{if(_){g();return}let t=ym.find(e=>e.id===p)?.label??String(p);h(e(`settings.voice.page.preview.voiceLine`,{voiceName:t}),{speakerId:p,speed:Mt.getState().speechRate})},[_,p,h,g,e]),b=Mt(e=>e.browserVoice),x=Mt(e=>e.setBrowserVoice),S=Mt(e=>e.openaiVoice),C=Mt(e=>e.setOpenaiVoice),w=Mt(e=>e.openaiApiKey),T=Mt(e=>e.setOpenaiApiKey),E=Mt(e=>e.openaiCompatibleUrl),D=Mt(e=>e.setOpenaiCompatibleUrl),O=Mt(e=>e.openaiCompatibleApiKey),k=Mt(e=>e.setOpenaiCompatibleApiKey),A=Mt(e=>e.openaiCompatibleVoice),j=Mt(e=>e.setOpenaiCompatibleVoice),M=Mt(e=>e.openaiCompatibleTtsModel),N=Mt(e=>e.setOpenaiCompatibleTtsModel),P=Mt(e=>e.showMessageTTSButtons),F=Mt(e=>e.ttsInputMode),I=Mt(e=>e.setTtsInputMode),L=Mt(e=>e.sttProvider),R=Mt(e=>e.setSttProvider),z=Mt(e=>e.sttServerUrl),B=Mt(e=>e.setSttServerUrl),V=Mt(e=>e.sttApiKey),H=Mt(e=>e.setSttApiKey),U=Mt(e=>e.sttModel),W=Mt(e=>e.setSttModel),ee=Mt(e=>e.sttLocalModel),G=Mt(e=>e.setSttLocalModel),te=Mt(e=>e.sttLanguage),ne=Mt(e=>e.setSttLanguage),re=Mt(e=>e.setShowMessageTTSButtons),ie=Mt(e=>e.dictationEnabled),ae=Mt(e=>e.setDictationEnabled),[oe,se]=(0,Q.useState)(!1),[ce,le]=(0,Q.useState)([]),[ue,de]=(0,Q.useState)(!1),[fe,pe]=(0,Q.useState)(null),[me,he]=(0,Q.useState)(!1),[ge,_e]=(0,Q.useState)(!1),[ve,K]=(0,Q.useState)(null),[ye,be]=(0,Q.useState)(!1),[xe,Se]=(0,Q.useState)(null),[Ce,we]=(0,Q.useState)([]),[Te,Ee]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>((async()=>{let e=await Cn.waitForVoices();we(e)})(),`speechSynthesis`in window&&(window.speechSynthesis.onvoiceschanged=()=>{we(window.speechSynthesis.getVoices())}),()=>{`speechSynthesis`in window&&(window.speechSynthesis.onvoiceschanged=null)}),[]);let De=(0,Q.useMemo)(()=>Ce.filter(e=>e.lang).sort((e,t)=>{let n=e.lang.startsWith(`en`),r=t.lang.startsWith(`en`);if(n&&!r)return-1;if(!n&&r)return 1;let i=e.lang.localeCompare(t.lang);return i===0?e.name.localeCompare(t.name):i}),[Ce]),Oe=(0,Q.useCallback)(()=>{if(Te){Cn.cancelSpeech(),Ee(!1);return}let t=Ce.find(e=>e.name===b),n=t?.name??e(`settings.voice.page.preview.browserVoiceFallback`),r=e(`settings.voice.page.preview.voiceLine`,{voiceName:n});Ee(!0);let a=new SpeechSynthesisUtterance(r);a.rate=i,a.pitch=o,a.volume=c,t&&(a.voice=t,a.lang=t.lang),a.onend=()=>Ee(!1),a.onerror=()=>Ee(!1),window.speechSynthesis.cancel(),window.speechSynthesis.speak(a)},[b,Ce,i,o,c,Te,e]);(0,Q.useEffect)(()=>()=>{Te&&Cn.cancelSpeech()},[Te]),(0,Q.useEffect)(()=>{if(!P||n!==`openai`&&n!==`openai-compatible`){he(w.trim().length>0);return}(async()=>{try{let e=(await(await l(`/api/tts/status`)).json()).available,t=w.trim().length>0;he(e||t)}catch{he(w.trim().length>0)}})()},[w,P,n]),(0,Q.useEffect)(()=>{if(!P){se(!1),le([]);return}l(`/api/tts/say/status`).then(e=>e.json()).then(e=>{if(se(e.available),e.voices){let t=e.voices.filter((e,t,n)=>n.findIndex(t=>t.name===e.name)===t).sort((e,t)=>e.name.localeCompare(t.name));le(t)}}).catch(()=>{se(!1)})},[P]);let ke=(0,Q.useCallback)(async()=>{if(fe){hm(fe),pe(null),de(!1);return}de(!0);let t=null;try{let n=await l(`/api/tts/say/speak`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({text:e(`settings.voice.page.preview.voiceLine`,{voiceName:d}),voice:d,rate:Math.round(100+(i-.5)*200)})});if(!n.ok)throw Error(`Preview failed`);let r=await n.blob(),a=URL.createObjectURL(r);t=new Audio(a),t.onended=()=>{hm(t),pe(null),de(!1)},t.onerror=()=>{hm(t),pe(null),de(!1)},pe(t),await t.play()}catch{hm(t),pe(null),de(!1)}},[d,i,fe,e]);(0,Q.useEffect)(()=>()=>{hm(fe)},[fe]);let Ae=(0,Q.useCallback)(async()=>{if(ve){hm(ve),K(null),_e(!1);return}_e(!0);let t=null;try{let n=await l(`/api/tts/speak`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({text:e(`settings.voice.page.preview.voiceLine`,{voiceName:S}),voice:S,speed:i,apiKey:w||void 0})});if(!n.ok){let e=await n.json().catch(()=>({error:`Unknown error`}));throw Error(e.error||`HTTP ${n.status}`)}let r=await n.blob(),a=URL.createObjectURL(r);t=new Audio(a),t.onended=()=>{hm(t),K(null),_e(!1)},t.onerror=()=>{hm(t),K(null),_e(!1)},K(t),await t.play()}catch{hm(t),K(null),_e(!1)}},[S,i,ve,w,e]);(0,Q.useEffect)(()=>()=>{hm(ve)},[ve]);let je=(0,Q.useCallback)(async()=>{if(xe){hm(xe),Se(null),be(!1);return}if(!E.trim())return;be(!0);let t=null;try{let n=await l(`/api/tts/speak`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({text:e(`settings.voice.page.preview.customServerLine`),voice:A,model:M||void 0,speed:i,baseURL:E,apiKey:O||void 0})});if(!n.ok){let e=await n.json().catch(()=>({error:`Unknown error`}));throw Error(e.error||`HTTP ${n.status}`)}let r=await n.blob(),a=URL.createObjectURL(r);t=new Audio(a),t.onended=()=>{hm(t),Se(null),be(!1)},t.onerror=()=>{hm(t),Se(null),be(!1)},Se(t),await t.play()}catch{hm(t),Se(null),be(!1)}},[E,A,M,O,i,xe,e]);(0,Q.useEffect)(()=>()=>{hm(xe)},[xe]);let Ne=`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(0,$.jsxs)(`div`,{className:`oc-settings-section-stack`,children:[(0,$.jsx)(`div`,{className:`space-y-1`,children:(0,$.jsx)(`h2`,{className:`typography-ui-header font-semibold text-foreground`,children:e(`settings.page.voice.title`)})}),(0,$.jsx)(`div`,{"data-settings-item":`voice.playback`,children:(0,$.jsxs)(vi,{label:e(`settings.voice.page.section.playbackAndSummary`),children:[(0,$.jsx)(Nr,{label:e(`settings.voice.page.field.messageReadAloudButton`),children:(0,$.jsx)(sn,{checked:P,onChange:re,ariaLabel:e(`settings.voice.page.field.messageReadAloudButtonAria`)})}),P&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Nr,{label:(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{children:e(`settings.voice.page.field.provider`)}),(0,$.jsxs)(hn,{children:[(0,$.jsx)(pn,{asChild:!0,children:(0,$.jsx)(X,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(mn,{sideOffset:8,className:`max-w-xs`,children:(0,$.jsxs)(`ul`,{className:`space-y-1`,children:[(0,$.jsxs)(`li`,{children:[(0,$.jsx)(`strong`,{children:e(`settings.voice.page.provider.browser`)}),` `,e(`settings.voice.page.tooltip.browser`)]}),(0,$.jsxs)(`li`,{children:[(0,$.jsx)(`strong`,{children:e(`settings.voice.page.provider.local`)}),` `,e(`settings.voice.page.tooltip.localTts`)]}),(0,$.jsxs)(`li`,{children:[(0,$.jsx)(`strong`,{children:`OpenAI:`}),` `,e(`settings.voice.page.tooltip.openai`)]}),(0,$.jsxs)(`li`,{children:[(0,$.jsx)(`strong`,{children:e(`settings.voice.page.provider.custom`)}),` `,e(`settings.voice.page.tooltip.custom`)]}),(0,$.jsxs)(`li`,{children:[(0,$.jsx)(`strong`,{children:e(`settings.voice.page.provider.say`)}),` `,e(`settings.voice.page.tooltip.say`)]})]})})]})]}),children:(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-1`,children:[(0,$.jsx)(J,{variant:`chip`,size:`xs`,"aria-pressed":n===`browser`,onClick:()=>r(`browser`),className:`!font-normal`,children:e(`settings.voice.page.provider.browser`)}),(0,$.jsx)(J,{variant:`chip`,size:`xs`,"aria-pressed":n===`local`,onClick:()=>r(`local`),className:`!font-normal`,children:e(`settings.voice.page.provider.local`)}),(0,$.jsx)(J,{variant:`chip`,size:`xs`,"aria-pressed":n===`openai`,onClick:()=>r(`openai`),className:`!font-normal`,children:`OpenAI`}),(0,$.jsx)(J,{variant:`chip`,size:`xs`,"aria-pressed":n===`openai-compatible`,onClick:()=>r(`openai-compatible`),className:`!font-normal`,children:e(`settings.voice.page.provider.custom`)}),oe&&(0,$.jsxs)(J,{variant:`chip`,size:`xs`,"aria-pressed":n===`say`,onClick:()=>r(`say`),className:`!font-normal`,children:[(0,$.jsx)(X,{name:`apple`,className:`w-3.5 h-3.5 mr-0.5`}),e(`settings.voice.page.provider.say`)]})]})}),n===`openai`&&(0,$.jsxs)(`div`,{className:`py-1.5`,children:[(0,$.jsx)(`span`,{className:q(`typography-ui-label text-foreground`,!me&&`text-[var(--status-error)]`),children:e(`settings.voice.page.field.apiKey`)}),(0,$.jsx)(`span`,{className:q(`typography-meta ml-2`,me?`text-muted-foreground`:`text-[var(--status-error)]/80`),children:e(me&&!w?`settings.voice.page.field.apiKeyHintUsingConfig`:me?`settings.voice.page.field.apiKeyHintProvide`:`settings.voice.page.field.apiKeyHintRequired`)}),(0,$.jsxs)(`div`,{className:`relative ml-auto mt-1.5 max-w-xs`,children:[(0,$.jsx)(fn,{type:`password`,value:w,onChange:e=>T(e.target.value),placeholder:`sk-...`,className:`w-full pr-8`}),w&&(0,$.jsx)(`button`,{type:`button`,onClick:()=>T(``),className:`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,children:(0,$.jsx)(X,{name:`close`,className:`w-3.5 h-3.5`})})]})]}),n===`openai-compatible`&&(0,$.jsxs)(`div`,{className:`py-1.5 space-y-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`span`,{className:q(`typography-ui-label text-foreground`,!E.trim()&&`text-[var(--status-error)]`),children:e(`settings.voice.page.field.serverUrl`)}),(0,$.jsx)(`span`,{className:`typography-meta ml-2 text-muted-foreground`,children:e(`settings.voice.page.field.serverUrlHint`)}),(0,$.jsxs)(`div`,{className:`relative ml-auto mt-1.5 max-w-xs`,children:[(0,$.jsx)(fn,{type:`text`,value:E,onChange:e=>D(e.target.value),placeholder:`http://localhost:8880/v1`,className:`w-full pr-8`}),E&&(0,$.jsx)(`button`,{type:`button`,onClick:()=>D(``),className:`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,children:(0,$.jsx)(X,{name:`close`,className:`w-3.5 h-3.5`})})]})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:`API Key`}),(0,$.jsx)(`span`,{className:`typography-meta ml-2 text-muted-foreground`,children:`Optional`}),(0,$.jsxs)(`div`,{className:`relative ml-auto mt-1.5 max-w-xs`,children:[(0,$.jsx)(fn,{type:`password`,value:O,onChange:e=>k(e.target.value),placeholder:`sk-...`,className:`w-full pr-8`}),O&&(0,$.jsx)(`button`,{type:`button`,onClick:()=>k(``),className:`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,children:(0,$.jsx)(X,{name:`close`,className:`w-3.5 h-3.5`})})]})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e(`settings.voice.page.field.model`)}),(0,$.jsx)(`div`,{className:`relative ml-auto mt-1.5 max-w-xs`,children:(0,$.jsx)(fn,{type:`text`,value:M,onChange:e=>N(e.target.value),placeholder:`speaches-ai/Kokoro-82M-v1.0-ONNX`,className:`w-full`})})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e(`settings.voice.page.field.voice`)}),(0,$.jsx)(`span`,{className:`typography-meta ml-2 text-muted-foreground`,children:e(`settings.voice.page.field.voiceIdentifierHint`)}),(0,$.jsxs)(`div`,{className:`mt-1.5 flex items-center justify-end gap-2`,children:[(0,$.jsx)(`div`,{className:`relative max-w-xs flex-1`,children:(0,$.jsx)(fn,{type:`text`,value:A,onChange:e=>j(e.target.value),placeholder:`af_sky`,className:`w-full`})}),(0,$.jsx)(J,{size:`xs`,variant:`ghost`,onClick:je,title:e(`settings.voice.page.actions.preview`),disabled:!E.trim(),children:ye?(0,$.jsx)(X,{name:`stop`,className:`w-3.5 h-3.5`}):(0,$.jsx)(X,{name:`play`,className:`w-3.5 h-3.5`})})]})]})]}),n===`local`&&(0,$.jsx)(xm,{}),(0,$.jsxs)(Nr,{label:e(`settings.voice.page.field.voice`),children:[n===`local`&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(ln,{value:String(p),onValueChange:e=>m(Number.parseInt(e,10)||0),children:[(0,$.jsx)(rn,{className:`w-fit`,children:(0,$.jsx)(dn,{placeholder:e(`settings.voice.page.field.selectVoicePlaceholder`),children:e=>ym.find(t=>String(t.id)===e)?.label??e})}),(0,$.jsx)(an,{children:ym.map(e=>(0,$.jsx)(tn,{value:String(e.id),children:e.label},e.id))})]}),(0,$.jsx)(J,{size:`xs`,variant:`ghost`,onClick:y,title:e(`settings.voice.page.actions.preview`),children:_?(0,$.jsx)(X,{name:`stop`,className:`w-3.5 h-3.5`}):(0,$.jsx)(X,{name:`play`,className:`w-3.5 h-3.5`})}),v?(0,$.jsx)(`span`,{className:`typography-meta text-[var(--status-error)]`,children:v}):null]}),n===`openai`&&me&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(ln,{value:S,onValueChange:C,children:[(0,$.jsx)(rn,{className:`w-fit`,children:(0,$.jsx)(dn,{placeholder:e(`settings.voice.page.field.selectVoicePlaceholder`)})}),(0,$.jsx)(an,{children:Sm.map(e=>(0,$.jsx)(tn,{value:e.value,children:e.label},e.value))})]}),(0,$.jsx)(J,{size:`xs`,variant:`ghost`,onClick:Ae,title:e(`settings.voice.page.actions.preview`),children:ge?(0,$.jsx)(X,{name:`stop`,className:`w-3.5 h-3.5`}):(0,$.jsx)(X,{name:`play`,className:`w-3.5 h-3.5`})})]}),n===`openai-compatible`&&(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:e(`settings.voice.page.field.configuredAbove`)}),n===`say`&&oe&&ce.length>0&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(ln,{value:d,onValueChange:f,children:[(0,$.jsx)(rn,{className:`w-fit`,children:(0,$.jsx)(dn,{placeholder:e(`settings.voice.page.field.selectVoicePlaceholder`)})}),(0,$.jsx)(an,{children:ce.map(e=>(0,$.jsx)(tn,{value:e.name,children:e.name},e.name))})]}),(0,$.jsx)(J,{size:`xs`,variant:`ghost`,onClick:ke,title:e(`settings.voice.page.actions.preview`),children:ue?(0,$.jsx)(X,{name:`stop`,className:`w-3.5 h-3.5`}):(0,$.jsx)(X,{name:`play`,className:`w-3.5 h-3.5`})})]}),n===`browser`&&De.length>0&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(ln,{value:b||`$auto`,onValueChange:e=>x(e===`$auto`?``:e),children:[(0,$.jsx)(rn,{className:`w-fit max-w-[200px]`,children:(0,$.jsx)(dn,{placeholder:e(`settings.voice.page.field.auto`)})}),(0,$.jsxs)(an,{children:[(0,$.jsx)(tn,{value:`$auto`,children:e(`settings.voice.page.field.auto`)}),De.map(e=>(0,$.jsxs)(tn,{value:e.name,children:[e.name,` (`,e.lang,`)`]},e.name))]})]}),(0,$.jsx)(J,{size:`xs`,variant:`ghost`,onClick:Oe,title:e(`settings.voice.page.actions.preview`),children:Te?(0,$.jsx)(X,{name:`stop`,className:`w-3.5 h-3.5`}):(0,$.jsx)(X,{name:`play`,className:`w-3.5 h-3.5`})})]})]}),(0,$.jsxs)(Nr,{label:e(`settings.voice.page.field.speechRate`),children:[!t&&(0,$.jsx)(`input`,{type:`range`,min:.5,max:2,step:.1,value:i,onChange:e=>a(Number(e.target.value)),className:Ne}),(0,$.jsx)(Fr,{value:i,onValueChange:a,min:.5,max:2,step:.1,className:`w-16 tabular-nums`})]}),(0,$.jsxs)(Nr,{label:e(`settings.voice.page.field.speechPitch`),children:[!t&&(0,$.jsx)(`input`,{type:`range`,min:.5,max:2,step:.1,value:o,onChange:e=>s(Number(e.target.value)),className:Ne}),(0,$.jsx)(Fr,{value:o,onValueChange:s,min:.5,max:2,step:.1,className:`w-16 tabular-nums`})]}),(0,$.jsxs)(Nr,{label:e(`settings.voice.page.field.speechVolume`),children:[!t&&(0,$.jsx)(`input`,{type:`range`,min:0,max:1,step:.1,value:c,onChange:e=>u(Number(e.target.value)),className:Ne}),t?(0,$.jsx)(Fr,{value:Math.round(c*100),onValueChange:e=>u(e/100),min:0,max:100,step:10,className:`w-16 tabular-nums`}):(0,$.jsxs)(`span`,{className:`typography-ui-label text-foreground tabular-nums min-w-[3rem] text-right`,children:[Math.round(c*100),`%`]})]}),(0,$.jsx)(Nr,{label:e(`settings.voice.page.field.ttsInputMode`),children:(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-1`,children:[(0,$.jsx)(J,{variant:`chip`,size:`xs`,"aria-pressed":F===`sanitized`,onClick:()=>I(`sanitized`),className:`!font-normal`,children:e(`settings.voice.page.field.ttsInputModeSanitized`)}),(0,$.jsx)(J,{variant:`chip`,size:`xs`,"aria-pressed":F===`raw`,onClick:()=>I(`raw`),className:`!font-normal`,children:e(`settings.voice.page.field.ttsInputModeRaw`)}),(0,$.jsx)(J,{variant:`chip`,size:`xs`,"aria-pressed":F===`summarized`,onClick:()=>I(`summarized`),className:`!font-normal`,children:e(`settings.voice.page.field.ttsInputModeSummarized`)})]})})]})]})}),(0,$.jsx)(`div`,{"data-settings-item":`voice.speech-recognition`,children:(0,$.jsxs)(vi,{label:e(`settings.voice.page.section.speechRecognition`),children:[(0,$.jsx)(Nr,{label:e(`settings.voice.page.field.enableVoiceInput`),children:(0,$.jsx)(sn,{checked:ie,onChange:ae,ariaLabel:e(`settings.voice.page.field.enableVoiceInputAria`)})}),ie&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Nr,{label:(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{children:e(`settings.voice.page.field.provider`)}),(0,$.jsxs)(hn,{children:[(0,$.jsx)(pn,{asChild:!0,children:(0,$.jsx)(X,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(mn,{sideOffset:8,className:`max-w-xs`,children:(0,$.jsxs)(`ul`,{className:`space-y-1`,children:[(0,$.jsxs)(`li`,{children:[(0,$.jsx)(`strong`,{children:e(`settings.voice.page.provider.local`)}),` `,e(`settings.voice.page.tooltip.sttLocal`)]}),(0,$.jsxs)(`li`,{children:[(0,$.jsx)(`strong`,{children:e(`settings.voice.page.provider.server`)}),` `,e(`settings.voice.page.tooltip.sttServer`)]})]})})]})]}),children:(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-1`,children:[(0,$.jsx)(J,{variant:`chip`,size:`xs`,"aria-pressed":L===`local`,onClick:()=>R(`local`),className:`!font-normal`,children:e(`settings.voice.page.provider.local`)}),(0,$.jsx)(J,{variant:`chip`,size:`xs`,"aria-pressed":L===`openai-compatible`,onClick:()=>R(`openai-compatible`),className:`!font-normal`,children:e(`settings.voice.page.provider.server`)})]})}),L===`local`&&(0,$.jsx)(Nr,{label:e(`settings.voice.page.field.model`),className:`oc-settings-split-row-stacked`,children:(0,$.jsx)(vm,{selectedModelId:ee,onSelect:G})}),L===`openai-compatible`&&(0,$.jsxs)(`div`,{className:`oc-settings-group-row space-y-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`span`,{className:q(`typography-ui-label text-foreground`,!z.trim()&&`text-[var(--status-error)]`),children:e(`settings.voice.page.field.serverUrl`)}),(0,$.jsx)(`span`,{className:`typography-meta ml-2 text-muted-foreground`,children:e(`settings.voice.page.field.sttServerUrlHint`)}),(0,$.jsxs)(`div`,{className:`relative ml-auto mt-1.5 max-w-xs`,children:[(0,$.jsx)(fn,{type:`text`,value:z,onChange:e=>B(e.target.value),placeholder:`http://localhost:8001/v1`,className:`w-full pr-8`}),z&&(0,$.jsx)(`button`,{type:`button`,onClick:()=>B(``),className:`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,children:(0,$.jsx)(X,{name:`close`,className:`w-3.5 h-3.5`})})]})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:`API Key`}),(0,$.jsx)(`span`,{className:`typography-meta ml-2 text-muted-foreground`,children:`Optional`}),(0,$.jsxs)(`div`,{className:`relative ml-auto mt-1.5 max-w-xs`,children:[(0,$.jsx)(fn,{type:`password`,value:V,onChange:e=>H(e.target.value),placeholder:`sk-...`,className:`w-full pr-8`}),V&&(0,$.jsx)(`button`,{type:`button`,onClick:()=>H(``),className:`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,children:(0,$.jsx)(X,{name:`close`,className:`w-3.5 h-3.5`})})]})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e(`settings.voice.page.field.model`)}),(0,$.jsx)(`div`,{className:`relative ml-auto mt-1.5 max-w-xs`,children:(0,$.jsx)(fn,{type:`text`,value:U,onChange:e=>W(e.target.value),placeholder:`deepdml/faster-whisper-large-v3-turbo-ct2`,className:`w-full`})})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e(`settings.voice.page.field.language`)}),(0,$.jsx)(`span`,{className:`typography-meta ml-2 text-muted-foreground`,children:e(`settings.voice.page.field.sttLanguageHint`)}),(0,$.jsx)(`div`,{className:`relative ml-auto mt-1.5 max-w-[8rem]`,children:(0,$.jsx)(fn,{type:`text`,value:te,onChange:e=>ne(e.target.value),placeholder:`auto`,className:`w-full`})})]})]})]})]})})]})},wm=e=>{let t=(0,Ii.c)(45),{className:n}=e,{t:r}=Me(),i=Hn(),a=ar(),o;t[0]===i.data?.providers?o=t[1]:(o=i.data?.providers??[],t[0]=i.data?.providers,t[1]=o);let s=o,c=i.data?.selectedId??null,l=pr(i.data),u;t[2]!==s||t[3]!==c||t[4]!==a||t[5]!==r?(u=e=>{!s.some(t=>t.id===e)||e===c||a.mutate(e,{onError:()=>{Y.error(r(`settings.openchamber.browserProvider.toast.selectFailed`))}})},t[2]=s,t[3]=c,t[4]=a,t[5]=r,t[6]=u):u=t[6];let d=Ae(u);if(!l)return null;let f;t[7]!==s||t[8]!==c?(f=s.find(e=>e.id===c)??null,t[7]=s,t[8]=c,t[9]=f):f=t[9];let p=f,m;t[10]===r?m=t[11]:(m=r(`settings.openchamber.browserProvider.label`),t[10]=r,t[11]=m);let h;t[12]===r?h=t[13]:(h=r(`settings.openchamber.browserProvider.info`),t[12]=r,t[13]=h);let g;t[14]===r?g=t[15]:(g=r(`settings.openchamber.browserProvider.aria`),t[14]=r,t[15]=g);let _=p?.id,v=a.isPending,y;t[16]===r?y=t[17]:(y=r(`settings.openchamber.browserProvider.aria`),t[16]=r,t[17]=y);let b;t[18]===r?b=t[19]:(b=r(`settings.openchamber.browserProvider.placeholder`),t[18]=r,t[19]=b);let x;t[20]!==p?.name||t[21]!==r?(x=p?.name??r(`settings.openchamber.browserProvider.placeholder`),t[20]=p?.name,t[21]=r,t[22]=x):x=t[22];let S;t[23]!==b||t[24]!==x?(S=(0,$.jsx)(dn,{placeholder:b,children:x}),t[23]=b,t[24]=x,t[25]=S):S=t[25];let C;t[26]!==S||t[27]!==y?(C=(0,$.jsx)(rn,{className:`oc-settings-inline-value w-fit max-w-full`,"aria-label":y,children:S}),t[26]=S,t[27]=y,t[28]=C):C=t[28];let w;t[29]===s?w=t[30]:(w=s.map(Tm),t[29]=s,t[30]=w);let T;t[31]===w?T=t[32]:(T=(0,$.jsx)(an,{children:w}),t[31]=w,t[32]=T);let E;t[33]!==d||t[34]!==a.isPending||t[35]!==C||t[36]!==T||t[37]!==_?(E=(0,$.jsxs)(ln,{value:_,onValueChange:d,disabled:v,children:[C,T]}),t[33]=d,t[34]=a.isPending,t[35]=C,t[36]=T,t[37]=_,t[38]=E):E=t[38];let D;return t[39]!==n||t[40]!==E||t[41]!==m||t[42]!==h||t[43]!==g?(D=(0,$.jsx)(Jr,{itemId:`sessions.browser-provider`,label:m,description:h,descriptionPlacement:`outside`,groupClassName:n,ariaLabel:g,children:E}),t[39]=n,t[40]=E,t[41]=m,t[42]=h,t[43]=g,t[44]=D):D=t[44],D};function Tm(e){return(0,$.jsx)(tn,{value:e.id,children:e.name},e.id)}var Em=()=>{let{t:e}=Me(),[t,n]=Q.useState(``),[r,i]=Q.useState(!0),[a,o]=Q.useState(!1),s=K(e=>e.showOpenCodeUpdateNotifications),c=K(e=>e.setShowOpenCodeUpdateNotifications);Q.useEffect(()=>{let e=!1;return(async()=>{try{let t=await l(`/api/config/settings`,{method:`GET`,headers:{Accept:`application/json`}});if(!t.ok)return;let r=await t.json().catch(()=>null);if(e||!r)return;let i=typeof r.opencodeBinary==`string`?r.opencodeBinary.trim():``;n(i)}catch{}finally{e||i(!1)}})(),()=>{e=!0}},[]);let d=Q.useCallback(async()=>{if(!(typeof window>`u`)&&u())try{let e=await T();e.success&&e.path&&e.path.trim().length>0&&n(e.path.trim())}catch{}},[]),f=Q.useCallback(async()=>{o(!0);try{let n=t.trim(),r=n.length>=2&&(n.startsWith(`"`)&&n.endsWith(`"`)||n.startsWith(`'`)&&n.endsWith(`'`))?n.slice(1,-1).trim():n;await M({opencodeBinary:r}),await pt({message:e(`settings.openchamber.opencodeCli.actions.restartingOpenCode`),mode:`projects`,scopes:[`all`]})}finally{o(!1)}},[e,t]),p=Q.useCallback(e=>{c(e),M({showOpenCodeUpdateNotifications:e})},[c]);return(0,$.jsxs)(vi,{label:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{children:e(`settings.openchamber.opencodeCli.title`)}),(0,$.jsxs)(hn,{children:[(0,$.jsx)(pn,{asChild:!0,children:(0,$.jsx)(X,{name:`information`,className:`h-3.5 w-3.5 cursor-help text-muted-foreground/60`})}),(0,$.jsxs)(mn,{sideOffset:8,className:`max-w-xs`,children:[e(`settings.openchamber.opencodeCli.tooltipPrefix`),` `,(0,$.jsx)(`code`,{className:`font-mono text-xs`,children:`opencode`}),e(`settings.openchamber.opencodeCli.tooltipSuffix`)]})]})]}),description:(0,$.jsxs)($.Fragment,{children:[e(`settings.openchamber.opencodeCli.tipPrefix`),` `,(0,$.jsx)(`span`,{className:`font-mono`,children:`OPENCODE_BINARY`}),` `,e(`settings.openchamber.opencodeCli.tipMiddle`),` `,(0,$.jsx)(`span`,{className:`font-mono`,children:`~/.config/openchamber/settings.json`}),`.`]}),children:[(0,$.jsx)(Nr,{itemId:`sessions.opencode-binary`,label:e(`settings.openchamber.opencodeCli.field.binaryPath`),children:(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center justify-end gap-2`,children:[(0,$.jsx)(fn,{value:t,onChange:e=>n(e.target.value),placeholder:e(`settings.openchamber.opencodeCli.field.binaryPathPlaceholder`),disabled:r||a,className:`h-7 min-w-0 flex-1 font-mono text-xs`}),(0,$.jsx)(J,{type:`button`,variant:`outline`,size:`xs`,onClick:d,disabled:r||a||!u(),className:`h-7 w-7 p-0`,"aria-label":e(`settings.openchamber.opencodeCli.actions.browseAria`),title:e(`settings.openchamber.opencodeCli.actions.browse`),children:(0,$.jsx)(X,{name:`folder`,className:`h-4 w-4`})})]})}),(0,$.jsxs)(`label`,{"data-settings-item":`sessions.opencode-update-notifications`,className:`oc-settings-group-row oc-settings-split-row cursor-pointer`,children:[(0,$.jsx)(`div`,{className:`oc-settings-split-row-copy`,children:(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e(`settings.openchamber.opencodeCli.field.showUpdateNotifications`)})}),(0,$.jsx)(`div`,{className:`oc-settings-split-row-control`,children:(0,$.jsx)(sn,{checked:s,onChange:p,ariaLabel:e(`settings.openchamber.opencodeCli.field.showUpdateNotificationsAria`)})})]}),(0,$.jsx)(`div`,{className:`oc-settings-group-row flex justify-end`,children:(0,$.jsx)(J,{type:`button`,size:`xs`,onClick:f,disabled:r||a,className:`shrink-0 !font-normal`,children:e(a?`settings.common.actions.saving`:`settings.openchamber.opencodeCli.actions.saveAndReload`)})})]})},Dm=[{id:`auto`,labelKey:`settings.openchamber.desktopNetwork.option.windowControlsAuto`},{id:`left`,labelKey:`settings.openchamber.desktopNetwork.option.windowControlsLeft`},{id:`right`,labelKey:`settings.openchamber.desktopNetwork.option.windowControlsRight`}],Om=()=>{let{t:e}=Me(),t=Q.useCallback(t=>e(t),[e]),n=u()&&_(),r=f(),i=K(e=>e.desktopWindowControlsPosition),a=K(e=>e.setDesktopWindowControlsPosition),[o,s]=Q.useState(!1),[c,l]=Q.useState(!1),[d,p]=Q.useState(!1),[g,y]=Q.useState(!1),[b,x]=Q.useState(!1),[C,w]=Q.useState(!1),[T,E]=Q.useState(!1),[D,O]=Q.useState(!1),[k,A]=Q.useState(!1),[j,N]=Q.useState(null);Q.useEffect(()=>{if(!n){s(!1);return}let e=!1;return(async()=>{let t=await m();e||(s(t?.supported===!0),l(t?.enabled===!0))})(),()=>{e=!0}},[n]),Q.useEffect(()=>{if(!n){y(!1);return}let e=!1;return(async()=>{let t=await h();e||(y(t?.supported===!0),x(t?.enabled===!0))})(),()=>{e=!0}},[n]),Q.useEffect(()=>{if(!n){E(!1);return}let e=!1;return(async()=>{let t=await v();e||(E(t?.supported===!0),O(t?.enabled===!0))})(),()=>{e=!0}},[n]);let P=Q.useCallback(e=>{a(e),M({desktopWindowControlsPosition:e})},[a]),F=Q.useCallback(async()=>{if(!o||d)return;let t=!c;l(t),p(!0),N(null);try{let n=await I(t);if(!n?.supported)throw Error(e(`settings.openchamber.desktopNetwork.error.launchAtLoginUnsupported`));l(n.enabled)}catch(n){l(!t),N(n instanceof Error?n.message:e(`settings.openchamber.desktopNetwork.error.launchAtLoginSaveFailed`))}finally{p(!1)}},[d,c,o,e]),L=Q.useCallback(async()=>{if(!g||C)return;let t=!b;x(t),w(!0),N(null);try{let n=await R(t);if(!n)throw Error(e(`settings.openchamber.desktopNetwork.error.minimizeToTraySaveFailed`));if(!n.supported)throw Error(e(`settings.openchamber.desktopNetwork.error.minimizeToTrayUnsupported`));x(n.enabled)}catch(n){x(!t),N(n instanceof Error?n.message:e(`settings.openchamber.desktopNetwork.error.minimizeToTraySaveFailed`))}finally{w(!1)}},[C,b,g,e]),z=Q.useCallback(async()=>{if(!T||k)return;let t=!D;O(t),A(!0),N(null);try{let n=await S(t);if(!n?.supported)throw Error(e(`settings.openchamber.desktopNetwork.error.keepAwakeUnsupported`));O(n.enabled)}catch(n){O(!t),N(n instanceof Error?n.message:e(`settings.openchamber.desktopNetwork.error.keepAwakeSaveFailed`))}finally{A(!1)}},[k,D,T,e]);return!n&&!r?null:(0,$.jsxs)(`div`,{className:`oc-settings-section-stack`,children:[r?(0,$.jsx)(vi,{label:e(`settings.openchamber.desktopNetwork.field.windowControlsPosition`),children:(0,$.jsx)(Nr,{itemId:`sessions.desktop-window-controls-position`,label:e(`settings.openchamber.desktopNetwork.field.windowControlsPosition`),description:e(`settings.openchamber.desktopNetwork.field.windowControlsPositionDescription`),children:(0,$.jsx)(`div`,{className:`flex flex-wrap items-center justify-end gap-1`,role:`group`,"aria-label":e(`settings.openchamber.desktopNetwork.field.windowControlsPositionAria`),children:Dm.map(e=>(0,$.jsx)(J,{type:`button`,variant:`chip`,size:`xs`,className:`!font-normal`,"aria-pressed":i===e.id,onClick:()=>P(e.id),children:t(e.labelKey)},e.id))})})}):null,!n||!(o||g||T||j)?null:(0,$.jsxs)(vi,{label:e(`settings.openchamber.desktopNetwork.title`),children:[o?(0,$.jsxs)(`div`,{"data-settings-item":`sessions.desktop-launch-at-login`,className:`oc-settings-group-row oc-settings-split-row group cursor-pointer`,role:`button`,tabIndex:0,onClick:F,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),F())},children:[(0,$.jsxs)(`div`,{className:`oc-settings-split-row-copy`,children:[(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:e(`settings.openchamber.desktopNetwork.field.launchAtLogin`)}),(0,$.jsx)(`div`,{className:`typography-meta text-muted-foreground`,children:e(`settings.openchamber.desktopNetwork.field.launchAtLoginDescription`)})]}),(0,$.jsx)(`div`,{className:`oc-settings-split-row-control`,children:(0,$.jsx)(sn,{checked:c,onChange:F,ariaLabel:e(`settings.openchamber.desktopNetwork.field.launchAtLoginAria`),disabled:d})})]}):null,g?(0,$.jsxs)(`div`,{"data-settings-item":`sessions.desktop-minimize-to-tray`,className:`oc-settings-group-row oc-settings-split-row group cursor-pointer`,role:`button`,tabIndex:0,onClick:L,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),L())},children:[(0,$.jsxs)(`div`,{className:`oc-settings-split-row-copy`,children:[(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:e(`settings.openchamber.desktopNetwork.field.minimizeToTray`)}),(0,$.jsx)(`div`,{className:`typography-meta text-muted-foreground`,children:e(`settings.openchamber.desktopNetwork.field.minimizeToTrayDescription`)})]}),(0,$.jsx)(`div`,{className:`oc-settings-split-row-control`,children:(0,$.jsx)(sn,{checked:b,onChange:L,ariaLabel:e(`settings.openchamber.desktopNetwork.field.minimizeToTrayAria`),disabled:C})})]}):null,T?(0,$.jsxs)(`div`,{"data-settings-item":`sessions.desktop-keep-awake`,className:`oc-settings-group-row oc-settings-split-row group cursor-pointer`,role:`button`,tabIndex:0,onClick:z,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),z())},children:[(0,$.jsxs)(`div`,{className:`oc-settings-split-row-copy`,children:[(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:e(`settings.openchamber.desktopNetwork.field.keepAwake`)}),(0,$.jsx)(`div`,{className:`typography-meta text-muted-foreground`,children:e(`settings.openchamber.desktopNetwork.field.keepAwakeDescription`)})]}),(0,$.jsx)(`div`,{className:`oc-settings-split-row-control`,children:(0,$.jsx)(sn,{checked:D,onChange:z,ariaLabel:e(`settings.openchamber.desktopNetwork.field.keepAwakeAria`),disabled:k})})]}):null,j?(0,$.jsx)(`div`,{className:`oc-settings-group-row typography-meta text-[var(--status-error)]`,children:j}):null]})]})},km=new Set([`shift`,`control`,`alt`,`meta`]),Am=e=>{if(km.has(e.key.toLowerCase()))return null;let t=[];(e.metaKey||e.ctrlKey)&&t.push(`mod`),e.shiftKey&&t.push(`shift`),e.altKey&&t.push(`alt`);let n=hr(e.key);return n?(t.push(n),In(t.join(`+`))):null},jm=()=>{let e=(0,Ii.c)(59),{t}=Me(),n;e[0]===t?n=e[1]:(n=e=>t(e),e[0]=t,e[1]=n);let r=n,i=K(Mm),a=K(Nm),o=K(Pm),s=K(Fm),c;if(e[2]===Symbol.for(`react.memo_cache_sentinel`)){bb0:{let e=Xn();if(!k()){c=e;break bb0}c=e.filter(Im)}e[2]=c}else c=e[2];let l=c,u;e[3]===r?u=e[4]:(u=(e,t)=>{let n=`settings.openchamber.keyboardShortcuts.action.${e}.label`,i=r(n);return i===n?t:i},e[3]=r,e[4]=u);let d=u,[f,p]=Q.useState(null),m;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(m={},e[5]=m):m=e[5];let[h,g]=Q.useState(m),[_,v]=Q.useState(``),[y,b]=Q.useState(``),[x,S]=Q.useState(null),C=Lm,w;e[6]===i?w=e[7]:(w=(e,t)=>{let n=In(t);for(let t of l){if(t.id===e)continue;let r=Yn(t.id,i);if(In(r)===n)return t.id}return null},e[6]=i,e[7]=w);let T=w,E;e[8]!==T||e[9]!==a||e[10]!==i||e[11]!==t?(E=(e,n)=>{let r=In(n),o=T(e,r);if(o){S({actionId:e,combo:r,conflictActionId:o}),v(``);return}let s={...i,[e]:r};a(e,r),C(s),S(null),v(``),b(Gn(r)?t(`settings.openchamber.keyboardShortcuts.warning.riskyBrowserShortcut`):``),g(t=>{let n={...t};return delete n[e],n})},e[8]=T,e[9]=a,e[10]=i,e[11]=t,e[12]=E):E=e[12];let D=E,O;e[13]!==x||e[14]!==a||e[15]!==i||e[16]!==t?(O=()=>{if(!x)return;let e={...i,[x.conflictActionId]:qn,[x.actionId]:x.combo};a(x.conflictActionId,qn),a(x.actionId,x.combo),C(e),S(null),v(``),b(Gn(x.combo)?t(`settings.openchamber.keyboardShortcuts.warning.riskyBrowserShortcut`):``),g(e=>{let t={...e};return delete t[x.actionId],t})},e[13]=x,e[14]=a,e[15]=i,e[16]=t,e[17]=O):O=e[17];let A=O,j;e[18]!==o||e[19]!==i?(j=e=>{let t={...i};delete t[e],o(e),C(t),g(t=>{let n={...t};return delete n[e],n}),S(null),v(``),b(``)},e[18]=o,e[19]=i,e[20]=j):j=e[20];let M=j,N;e[21]===t?N=e[22]:(N=t(`settings.openchamber.keyboardShortcuts.title`),e[21]=t,e[22]=N);let P;e[23]===N?P=e[24]:(P=(0,$.jsx)(`span`,{children:N}),e[23]=N,e[24]=P);let F;e[25]===s?F=e[26]:(F=()=>{s(),C({}),g({}),S(null),v(``),b(``)},e[25]=s,e[26]=F);let I;e[27]===t?I=e[28]:(I=t(`settings.openchamber.keyboardShortcuts.actions.resetAll`),e[27]=t,e[28]=I);let L;e[29]!==F||e[30]!==I?(L=(0,$.jsx)(J,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal`,onClick:F,children:I}),e[29]=F,e[30]=I,e[31]=L):L=e[31];let R;e[32]===Symbol.for(`react.memo_cache_sentinel`)?(R=(0,$.jsx)(pn,{asChild:!0,children:(0,$.jsx)(X,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),e[32]=R):R=e[32];let z;e[33]===t?z=e[34]:(z=t(`settings.openchamber.keyboardShortcuts.tooltip`),e[33]=t,e[34]=z);let B;e[35]===z?B=e[36]:(B=(0,$.jsxs)(hn,{children:[R,(0,$.jsx)(mn,{sideOffset:8,className:`max-w-xs`,children:z})]}),e[35]=z,e[36]=B);let V;e[37]!==L||e[38]!==B||e[39]!==P?(V=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[P,L,B]}),e[37]=L,e[38]=B,e[39]=P,e[40]=V):V=e[40];let H;e[41]!==A||e[42]!==_||e[43]!==x||e[44]!==t||e[45]!==y?(H=(_||y||x)&&(0,$.jsxs)(`div`,{className:`mb-2 space-y-2 px-1`,children:[x&&(0,$.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:[(0,$.jsx)(`span`,{className:`typography-meta text-foreground`,children:t(`settings.openchamber.keyboardShortcuts.overwritePrompt`)}),(0,$.jsxs)(`div`,{className:`flex gap-2 shrink-0`,children:[(0,$.jsx)(J,{type:`button`,size:`xs`,className:`!font-normal`,onClick:A,children:t(`settings.openchamber.keyboardShortcuts.actions.overwrite`)}),(0,$.jsx)(J,{type:`button`,size:`xs`,className:`!font-normal`,variant:`ghost`,onClick:()=>S(null),children:t(`settings.common.actions.cancel`)})]})]}),_&&(0,$.jsx)(`div`,{className:`rounded-lg border border-[var(--status-error-border)] bg-[var(--status-error-background)] p-3 typography-meta text-foreground`,children:_}),y&&(0,$.jsx)(`div`,{className:`rounded-lg border border-[var(--status-warning-border)] bg-[var(--status-warning-background)] p-3 typography-meta text-foreground`,children:y})]}),e[41]=A,e[42]=_,e[43]=x,e[44]=t,e[45]=y,e[46]=H):H=e[46];let U;e[47]!==d||e[48]!==f||e[49]!==h||e[50]!==M||e[51]!==D||e[52]!==i||e[53]!==t?(U=l.map(e=>{let n=Yn(e.id,i),r=h[e.id],a=r??n,o=typeof r==`string`&&In(r)!==In(n);return(0,$.jsxs)(Nr,{label:d(e.id,e.label),children:[(0,$.jsx)(fn,{readOnly:!0,value:f===e.id?t(`settings.openchamber.keyboardShortcuts.field.pressKeys`):rr(a),onFocus:()=>{p(e.id),v(``)},onBlur:()=>{f===e.id&&p(null)},onKeyDown:t=>{if(t.preventDefault(),t.stopPropagation(),t.key===`Escape`){p(null);return}let n=Am(t);n&&(g(t=>({...t,[e.id]:n})),p(null),S(null),v(``))},className:`w-40 min-w-0 typography-ui-label text-right`}),(0,$.jsx)(J,{type:`button`,variant:`secondary`,size:`xs`,className:`!font-normal`,onClick:()=>{let n=h[e.id];if(!n){v(t(`settings.openchamber.keyboardShortcuts.error.captureFirst`));return}D(e.id,n)},disabled:!o,children:t(`settings.common.actions.saveChanges`)}),(0,$.jsx)(J,{type:`button`,size:`xs`,className:`!font-normal`,variant:`ghost`,onClick:()=>M(e.id),children:t(`settings.common.actions.reset`)})]},e.id)}),e[47]=d,e[48]=f,e[49]=h,e[50]=M,e[51]=D,e[52]=i,e[53]=t,e[54]=U):U=e[54];let W;return e[55]!==V||e[56]!==H||e[57]!==U?(W=(0,$.jsxs)(vi,{itemId:`shortcuts.keyboard-shortcuts`,label:V,children:[H,U]}),e[55]=V,e[56]=H,e[57]=U,e[58]=W):W=e[58],W};function Mm(e){return e.shortcutOverrides}function Nm(e){return e.setShortcutOverride}function Pm(e){return e.clearShortcutOverride}function Fm(e){return e.resetAllShortcutOverrides}function Im(e){return e.id!==`toggle_prompt_navigator`}function Lm(e){M({shortcutOverrides:e})}var Rm=()=>{let e=(0,Ii.c)(2),[t,n]=Q.useState(0),i,a;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=()=>r(()=>n(Jm)),a=[],e[0]=i,e[1]=a):(i=e[0],a=e[1]),Q.useEffect(i,a),t},zm=e=>{let t=(0,Ii.c)(25),{section:n,flowMobile:r}=e,i=r!==void 0&&r,{isMobile:a}=yr();Rm();let o;t[0]===a?o=t[1]:(o=a&&N(),t[0]=a,t[1]=o);let s=o,c;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(c=k(),t[2]=c):c=t[2];let l=c,d;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(d=u()&&(_()||f()),t[3]=d):d=t[3];let p=d;if(!n){let e;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Gp,{}),t[4]=e):e=t[4];let n;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(`div`,{className:`oc-settings-page-section`,children:(0,$.jsx)(om,{})}),t[5]=n):n=t[5];let r,i,a,o;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsx)(`div`,{className:`oc-settings-page-section`,children:(0,$.jsx)(dm,{})}),a=p&&(0,$.jsx)(`div`,{className:`oc-settings-page-section`,children:(0,$.jsx)(Om,{})}),o=!l&&(0,$.jsx)(`div`,{className:`oc-settings-page-section`,children:(0,$.jsx)(Em,{})}),r=(0,$.jsx)(wm,{className:`oc-settings-page-section`}),t[6]=r,t[7]=i,t[8]=a,t[9]=o):(r=t[6],i=t[7],a=t[8],o=t[9]);let c;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(`div`,{className:`oc-settings-page-section`,children:(0,$.jsx)(Xp,{})}),t[10]=c):c=t[10];let u;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,$.jsx)(`div`,{className:`oc-settings-page-section`,children:(0,$.jsx)(im,{})}),t[11]=u):u=t[11];let d;t[12]===s?d=t[13]:(d=s&&(0,$.jsx)(`div`,{className:`oc-settings-page-section`,children:(0,$.jsx)(Ki,{})}),t[12]=s,t[13]=d);let f;return t[14]===d?f=t[15]:(f=(0,$.jsx)(Sr,{outerClassName:`h-full`,className:`w-full`,children:(0,$.jsxs)(`div`,{className:`oc-settings-page-content openchamber-page-body mx-auto max-w-3xl p-3 sm:p-6 sm:pt-8`,children:[e,n,i,a,o,r,c,u,d]})}),t[14]=d,t[15]=f),f}let m;t[16]!==i||t[17]!==n?(m=()=>{switch(n){case`visual`:return(0,$.jsx)(Vm,{mobile:i});case`chat`:return(0,$.jsx)(Hm,{});case`sessions`:return(0,$.jsx)(Um,{});case`summary-ai`:return(0,$.jsx)(dm,{});case`shortcuts`:return(0,$.jsx)(Bm,{});case`git`:return(0,$.jsx)(Wm,{});case`github`:return(0,$.jsx)(Gm,{});case`notifications`:return(0,$.jsx)(Km,{});case`voice`:return(0,$.jsx)(qm,{});default:return null}},t[16]=i,t[17]=n,t[18]=m):m=t[18];let h=m,g;t[19]===h?g=t[20]:(g=h(),t[19]=h,t[20]=g);let v;t[21]===g?v=t[22]:(v=(0,$.jsx)(`div`,{className:`oc-settings-page-content openchamber-page-body mx-auto max-w-3xl p-3 sm:p-6 sm:pt-8`,children:g}),t[21]=g,t[22]=v);let y=v;if(i)return y;let b;return t[23]===y?b=t[24]:(b=(0,$.jsx)(Sr,{outerClassName:`h-full`,className:`w-full`,children:y}),t[23]=y,t[24]=b),b},Bm=()=>{let e=(0,Ii.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(jm,{}),e[0]=t):t=e[0],t},Vm=e=>{let t=(0,Ii.c)(5),{mobile:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=k(),t[0]=r):r=t[0];let i=r,a;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(a=i?[]:[`weekStart`],t[1]=a):a=t[1];let o;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=[`theme`,`sidebarBrand`,`pwaInstallName`,`pwaOrientation`,`mobileKeyboardMode`,`timeFormat`,...a,`iosNativeUi`,`fontSize`,`codeFontSize`,`terminalFontSize`,`editorFontSize`,`fileEditorKeymap`,`spacing`,`inputBarOffset`,`expandedEditorToolbar`,...i?[]:[`terminalQuickKeys`],`reportUsage`],t[2]=o):o=t[2];let s;return t[3]===n?s=t[4]:(s=(0,$.jsx)(Gp,{mobile:n,visibleSettings:o}),t[3]=n,t[4]=s),s},Hm=()=>{let e=(0,Ii.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=k(),e[0]=t):t=e[0];let n=t,r;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(Gp,{visibleSettings:[`chatRenderMode`,`messageTransport`,`activityRenderMode`,`expandedTools`,`userMessageRendering`,`mermaidRendering`,`diffLayout`,`followUpBehavior`,`sessionGoal`,`questionAutoDelegate`,`sessionAssist`,`subagentReadOnlyBanner`,`reasoning`,`collapsibleUserMessages`,`stickyUserHeader`,...n?[]:[`promptNavigatorEnabled`],`wideChatLayout`,`codeBlockLineWrap`,`showAssistantTps`,`dotfiles`,`fileViewerPreview`,`persistDraft`,`showTurnChangedFiles`,`inputSpellcheck`]}),e[1]=r):r=e[1],r},Um=()=>{let e=(0,Ii.c)(8),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=k(),e[0]=t):t=e[0];let n=t;Rm();let r;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(r=u()&&(_()||f()),e[1]=r):r=e[1];let i=r,a,o,s,c;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,$.jsx)(om,{}),o=i&&(0,$.jsx)(`div`,{className:`oc-settings-page-section`,children:(0,$.jsx)(Om,{})}),s=!n&&(0,$.jsx)(`div`,{className:`oc-settings-page-section`,children:(0,$.jsx)(Em,{})}),c=(0,$.jsx)(wm,{}),e[2]=a,e[3]=o,e[4]=s,e[5]=c):(a=e[2],o=e[3],s=e[4],c=e[5]);let l;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(`div`,{className:`oc-settings-page-section`,children:(0,$.jsx)(Xp,{})}),e[6]=l):l=e[6];let d;return e[7]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,$.jsxs)(`div`,{className:`oc-settings-section-stack`,children:[a,o,s,c,l,(0,$.jsx)(`div`,{className:`oc-settings-page-section`,children:(0,$.jsx)(im,{})})]}),e[7]=d):d=e[7],d},Wm=()=>{let e=(0,Ii.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(`div`,{className:`oc-settings-section-stack`,children:(0,$.jsx)(pp,{})}),e[0]=t):t=e[0],t},Gm=()=>{let e=(0,Ii.c)(1);if(k())return null;let t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(mp,{}),e[0]=t):t=e[0],t},Km=()=>{let e=(0,Ii.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(mm,{}),e[0]=t):t=e[0],t},qm=()=>{let e=(0,Ii.c)(1);if(k())return null;let t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(Cm,{}),e[0]=t):t=e[0],t};function Jm(e){return e+1}var Ym=()=>{let e=(0,Ii.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(El,{children:(0,$.jsx)(ai,{mode:`page`})}),e[0]=t):t=e[0],t},Xm=[{id:`chat.question-auto-delegate`,page:`chat`,titleKey:`settings.chat.questionDelegate.label`,descriptionKey:`settings.chat.questionDelegate.description`,keywords:[`question`,`auto`,`delegate`,`30`,`subagent`,`托管`,`倒计时`]},{id:`instances.manage`,page:`instances`,titleKey:`mobile.settings.switchInstance`,keywords:[`instance`,`server`,`connection`,`switch`],isAvailable:e=>e.isMobile},{id:`global-config.editor`,page:`global-config`,titleKey:`settings.globalConfig.title`,descriptionKey:`settings.globalConfig.description`,keywords:[`opencode.json`,`opencode.jsonc`,`oh-my-opencode-slim`,`oh-my-openagent`,`json`,`jsonc`]},{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:e=>!e.isVSCode},{id:`appearance.light-theme`,page:`appearance`,titleKey:`settings.openchamber.visual.field.lightTheme`,keywords:[`theme`,`color`,`light mode`],isAvailable:e=>!e.isVSCode},{id:`appearance.dark-theme`,page:`appearance`,titleKey:`settings.openchamber.visual.field.darkTheme`,keywords:[`theme`,`color`,`dark mode`],isAvailable:e=>!e.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:e=>e.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:e=>e.isMac},{id:`appearance.sidebar-brand`,page:`appearance`,titleKey:`settings.openchamber.visual.field.sidebarBrand`,descriptionKey:`settings.openchamber.visual.field.sidebarBrandHint`,keywords:[`logo`,`brand`,`wordmark`,`sidebar`]},{id:`appearance.pwa-install-name`,page:`appearance`,titleKey:`settings.openchamber.visual.field.installAppName`,descriptionKey:`settings.openchamber.visual.field.installAppNameHint`,keywords:[`pwa`,`installed app`],isAvailable:e=>e.isWeb&&!e.isDesktop&&!e.isVSCode},{id:`appearance.pwa-orientation`,page:`appearance`,titleKey:`settings.openchamber.visual.field.installOrientation`,descriptionKey:`settings.openchamber.visual.field.installOrientationHint`,keywords:[`pwa`,`portrait`,`landscape`],isAvailable:e=>e.isWeb&&!e.isDesktop&&!e.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:e=>e.isMobile&&e.isWeb&&!e.isDesktop&&!e.isVSCode},{id:`appearance.ios-native-ui`,page:`appearance`,titleKey:`settings.openchamber.visual.field.iosNativeUi`,descriptionKey:`settings.openchamber.visual.field.iosNativeUiHint`,keywords:[`ios`,`native`,`webview`,`composer`,`tab bar`,`live activity`],isAvailable:()=>Er()},{id:`appearance.interface-font-size`,page:`appearance`,titleKey:`settings.openchamber.visual.field.interfaceFontSize`,keywords:[`font`,`text size`,`ui scale`]},{id:`appearance.code-font-size`,page:`appearance`,titleKey:`settings.openchamber.visual.field.codeFontSize`,keywords:[`code`,`font`,`text size`,`diff`]},{id:`appearance.terminal-font-size`,page:`appearance`,titleKey:`settings.openchamber.visual.field.terminalFontSize`,keywords:[`terminal`,`font`,`text size`]},{id:`appearance.editor-font-size`,page:`appearance`,titleKey:`settings.openchamber.visual.field.editorFontSize`,keywords:[`editor`,`font`,`text size`,`code`]},{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:e=>!e.isMobile&&!e.isDesktop&&!e.isVSCode},{id:`about.beta-updates`,page:`about`,titleKey:`settings.openchamber.about.betaUpdates.label`,descriptionKey:`settings.openchamber.about.betaUpdates.description`,keywords:[`beta`,`updates`,`channel`,`ota`],isAvailable:e=>e.isMobile&&me()},{id:`about.diagnostics`,page:`about`,titleKey:`settings.openchamber.about.diagnostics.label`,keywords:[`diagnostics`,`logs`,`feat`,`transcript`,`task`]},{id:`about.export-diagnostics`,page:`about`,titleKey:`settings.openchamber.about.diagnostics.export`,keywords:[`diagnostics`,`logs`,`export`,`feat`,`transcript`,`task`],isAvailable:()=>jt()},{id:`appearance.usage-reports`,page:`appearance`,titleKey:`settings.openchamber.visual.field.sendAnonymousUsageReports`,descriptionKey:`settings.openchamber.visual.field.sendAnonymousUsageReportsHint`,keywords:[`telemetry`,`analytics`]},{id:`appearance.transcript-cache`,page:`appearance`,titleKey:`settings.openchamber.visual.transcriptCache.label`,descriptionKey:`settings.openchamber.visual.transcriptCache.description`,keywords:[`cache`,`local data`,`conversation history`,`transcript`,`privacy`]},{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.session-assistance`,page:`chat`,titleKey:`settings.openchamber.visual.section.sessionAssistance`,keywords:[`title`,`assist`,`subagent`]},{id:`chat.session-title-refresh`,page:`chat`,titleKey:`settings.openchamber.visual.field.sessionTitleRefresh`,keywords:[`title`,`rename`,`refresh`,`throttle`,`small model`,`summary`]},{id:`chat.session-goal`,page:`chat`,titleKey:`settings.openchamber.visual.field.sessionGoal`,keywords:[`goal`,`objective`,`auto continue`,`small model`],isAvailable:e=>!e.isVSCode},{id:`chat.session-goal-budget`,page:`chat`,titleKey:`settings.openchamber.visual.goal.budgetLabel`,keywords:[`goal`,`budget`,`tokens`,`limit`],isAvailable:e=>!e.isVSCode},{id:`chat.reasoning-traces`,page:`chat`,titleKey:`settings.openchamber.visual.field.showReasoningTraces`,keywords:[`thinking`,`reasoning`]},{id:`chat.reasoning`,page:`chat`,titleKey:`settings.openchamber.visual.section.reasoning`,keywords:[`thinking`,`traces`]},{id:`chat.sticky-user-header`,page:`chat`,titleKey:`settings.openchamber.visual.field.stickyUserHeader`,keywords:[`messages`,`header`]},{id:`chat.prompt-navigator`,page:`chat`,titleKey:`settings.openchamber.visual.field.promptNavigatorEnabled`,keywords:[`prompt`,`navigator`,`navigation`,`timeline`,`scroll`],isAvailable:e=>!e.isVSCode},{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.message-appearance`,page:`chat`,titleKey:`settings.openchamber.visual.section.messageAppearance`,keywords:[`layout`,`messages`,`appearance`]},{id:`chat.code-block-line-wrap`,page:`chat`,titleKey:`settings.openchamber.visual.field.codeBlockLineWrap`,keywords:[`code`,`wrap`,`line wrap`,`markdown`]},{id:`chat.inline-assistant-actions`,page:`chat`,titleKey:`settings.openchamber.visual.field.showSplitAssistantMessageActions`,descriptionKey:`settings.openchamber.visual.field.showSplitAssistantMessageActionsTooltip`,keywords:[`copy`,`read aloud`],isAvailable:()=>!1},{id:`chat.assistant-tps`,page:`chat`,titleKey:`settings.openchamber.visual.field.showAssistantTps`,descriptionKey:`settings.openchamber.visual.field.showAssistantTpsTooltip`,keywords:[`tps`,`tokens`,`speed`,`rate`,`tok/s`,`throughput`]},{id:`chat.subagent-read-only-banner`,page:`chat`,titleKey:`settings.openchamber.visual.field.allowPromptingSubagentSessions`,keywords:[`subagent`,`read only`,`prompt`,`banner`]},{id:`chat.tool-file-icons`,page:`chat`,titleKey:`settings.openchamber.visual.field.showToolFileIcons`,keywords:[`tools`,`files`,`icons`],isAvailable:()=>!1},{id:`chat.tools-and-files`,page:`chat`,titleKey:`settings.openchamber.visual.section.toolsAndFiles`,keywords:[`tools`,`files`,`dotfiles`]},{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:e=>!e.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.composer`,page:`chat`,titleKey:`settings.openchamber.visual.section.composer`,keywords:[`input`,`draft`,`spellcheck`]},{id:`chat.spellcheck`,page:`chat`,titleKey:`settings.openchamber.visual.field.enableSpellcheckInTextInputs`,keywords:[`spelling`,`input`],isAvailable:e=>!e.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.browser-provider`,page:`sessions`,titleKey:`settings.openchamber.browserProvider.label`,descriptionKey:`settings.openchamber.browserProvider.info`,keywords:[`browser`,`extension`,`provider`,`live view`],isAvailable:()=>pr(Zn())},{id:`sessions.deletion-dialog`,page:`sessions`,titleKey:`settings.openchamber.defaults.field.showDeletionDialog`,keywords:[`delete`,`confirmation`]},{id:`summary-ai.configuration`,page:`summary-ai`,titleKey:`settings.openchamber.defaults.summary.title`,descriptionKey:`settings.openchamber.defaults.summary.description`,keywords:[`summary`,`commit`,`session title`,`prompt`,`provider`,`custom api`,`base url`,`api token`]},{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:`archived-sessions.manage`,page:`archived-sessions`,titleKey:`settings.openchamber.archivedSessions.title`,descriptionKey:`settings.openchamber.archivedSessions.description`,keywords:[`archive`,`archived`,`restore`,`preview`,`history`]},{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:e=>e.isDesktopLocalOrigin},{id:`sessions.desktop-window-controls-position`,page:`sessions`,titleKey:`settings.openchamber.desktopNetwork.field.windowControlsPosition`,descriptionKey:`settings.openchamber.desktopNetwork.field.windowControlsPositionDescription`,keywords:[`desktop`,`window`,`controls`,`minimize`,`maximize`,`close`,`titlebar`,`linux`,`windows`],isAvailable:e=>e.isDesktop&&(e.isWindows||!e.isMac)},{id:`sessions.desktop-minimize-to-tray`,page:`sessions`,titleKey:`settings.openchamber.desktopNetwork.field.minimizeToTray`,descriptionKey:`settings.openchamber.desktopNetwork.field.minimizeToTrayDescription`,keywords:[`desktop`,`tray`,`system tray`,`minimize`,`close`,`background`,`windows`],isAvailable:e=>e.isDesktopLocalOrigin&&e.isWindows},{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:e=>e.isDesktopLocalOrigin},{id:`remote-instances.desktop-ui-password`,page:`remote-instances`,titleKey:`settings.openchamber.desktopPassword.field.password`,descriptionKey:`settings.openchamber.desktopPassword.field.passwordDescription`,keywords:[`desktop`,`password`,`auth`,`login`],isAvailable:e=>e.isDesktopLocalOrigin},{id:`remote-instances.desktop-lan-access`,page:`remote-instances`,titleKey:`settings.openchamber.desktopNetwork.field.allowLanAccess`,descriptionKey:`settings.openchamber.desktopNetwork.field.allowLanAccessDescription`,keywords:[`desktop`,`lan`,`network`,`phone`,`tablet`],isAvailable:e=>e.isDesktopLocalOrigin},{id:`sessions.opencode-binary`,page:`sessions`,titleKey:`settings.openchamber.opencodeCli.field.binaryPath`,keywords:[`opencode`,`cli`,`binary`,`path`],isAvailable:e=>!e.isVSCode},{id:`sessions.opencode-update-notifications`,page:`sessions`,titleKey:`settings.openchamber.opencodeCli.field.showUpdateNotifications`,keywords:[`opencode`,`cli`,`updates`],isAvailable:e=>!e.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`,`relay`,`devices`,`connect from anywhere`],isAvailable:e=>!e.isVSCode},{id:`remote-instances.instances`,page:`remote-instances`,titleKey:`settings.remoteInstances.sidebar.title`,descriptionKey:`settings.remoteInstances.sidebar.description`,keywords:[`import link`,`pairing link`,`connect link`,`ssh`,`remote instance`,`host switcher`],isAvailable:e=>e.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:`assistants.instance-enabled`,page:`assistants`,titleKey:`assistants.settings.instanceEnabled`,descriptionKey:`assistants.settings.description`,keywords:[`assistant`,`enable`,`feature`]},{id:`assistants.create`,page:`assistants`,titleKey:`assistants.settings.create`,keywords:[`assistant`,`new`,`add`]},{id:`assistants.name`,page:`assistants`,titleKey:`assistants.settings.name`,keywords:[`assistant`,`name`]},{id:`assistants.default-share`,page:`assistants`,titleKey:`assistants.settings.defaultShare`,keywords:[`share`,`default`,`mobile`]},{id:`assistants.prompt`,page:`assistants`,titleKey:`assistants.settings.defaultPrompt`,keywords:[`prompt`,`instructions`]},{id:`assistants.model`,page:`assistants`,titleKey:`assistants.settings.model`,keywords:[`provider`,`model`]},{id:`assistants.workspace`,page:`assistants`,titleKey:`assistants.settings.workspace`,keywords:[`path`,`directory`,`workspace`]},{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.scope`,page:`agents`,titleKey:`settings.agents.page.field.scope`,keywords:[`scope`,`project`,`user`,`global`]},{id:`agents.model`,page:`agents`,titleKey:`settings.agents.page.field.overrideModel`,keywords:[`model`,`provider`,`variant`]},{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:e=>!e.isVSCode},{id:`magic-prompts.instructions`,page:`magic-prompts`,titleKey:`settings.magicPrompts.page.block.instructions`,keywords:[`hidden prompt`,`instructions`,`template`],isAvailable:e=>!e.isVSCode},{id:`magic-prompts.reset-overrides`,page:`magic-prompts`,titleKey:`settings.magicPrompts.page.actions.resetAllOverrides`,keywords:[`reset`,`default prompts`,`overrides`],isAvailable:e=>!e.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:`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:e=>e.isWeb&&!e.isDesktop&&!e.isVSCode}];function Zm(e){return e.trim().toLocaleLowerCase()}function Qm({query:e,runtimeCtx:t,visiblePageSlugs:n,t:r,getPageTitle:i}){let a=Zm(e);if(!a)return[];let o=n?new Set(n):null,s=a.split(/\s+/).filter(Boolean);return Xm.flatMap(e=>{if(o&&!o.has(e.page))return[];let n=ii(e.page);if(!n||n.isAvailable&&!n.isAvailable(t)||e.isAvailable&&!e.isAvailable(t))return[];let a=r(e.titleKey),c=e.descriptionKey?r(e.descriptionKey):null,l=Zm([a,c,i(e.page),...e.keywords??[]].filter(Boolean).join(` `));return s.every(e=>l.includes(e))?[{...e,title:a,description:c,pageTitle:i(e.page)}]:[]})}function $m(e){let t=(0,Ii.c)(10),{label:n,children:r,ariaLabel:i,className:a,borderless:o}=e,s=o!==void 0&&o,c;t[0]===a?c=t[1]:(c=q(`oc-mobile-settings-group`,a),t[0]=a,t[1]=c);let l=s&&`oc-mobile-settings-card-borderless`,u;t[2]===l?u=t[3]:(u=q(`oc-mobile-settings-card`,l),t[2]=l,t[3]=u);let d;return t[4]!==i||t[5]!==r||t[6]!==n||t[7]!==c||t[8]!==u?(d=(0,$.jsx)(vi,{label:n,ariaLabel:i,className:c,cardClassName:u,children:r}),t[4]=i,t[5]=r,t[6]=n,t[7]=c,t[8]=u,t[9]=d):d=t[9],d}var eh=t({SettingsView:()=>gh,getSettingsNavIcon:()=>mh}),th=176,nh=280,rh=8,ih=`__openchamberSettingsDetail`;function ah(e){return Math.min(nh,Math.max(th,e))}var oh={icon:`chat-thread`},sh=`__add_provider__`;function ch(e,t){return{isVSCode:k(),isWeb:!e&&N(),isDesktop:e,isMobile:t}}function lh(e,t){return!e.isAvailable||e.isAvailable(t)}function uh(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function dh(e,t){let n=new Set(t),r=e,i=1;for(;n.has(r);)r=`${e}-${i}`,i+=1;return r}function fh(e){if(!uh(e))return null;let t=e[ih];if(!uh(t))return null;let n=t.page,r=t.stage;return typeof n!=`string`||r!==`page-content`?null:{page:hi(n),stage:r}}function ph(){return typeof window>`u`||!uh(window.history.state)?{}:window.history.state}function mh(e){switch(e){case`projects`:return`folders`;case`instances`:return`server`;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 oh.icon;case`notifications`:return`notification-3`;case`shortcuts`:return`command`;case`sessions`:return`chat-history`;case`archived-sessions`:return`archive`;case`summary-ai`:return`ai-generate-2`;case`providers`:return`cloud`;case`agents`:return`node-tree`;case`assistants`:return`robot-2`;case`behavior`:return`brain`;case`commands`:return`slash-commands-2`;case`mcp`:return null;case`plugins`:return`code-box`;case`global-config`:return`settings-3`;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`about`:return`information`;case`home`:return null;default:return`robot-2`}}var hh=e=>{let t=(0,Ii.c)(95),{onOpen:n}=e,{t:r}=Me(),i;t[0]===r?i=t[1]:(i=r(`settings.view.home.title`),t[0]=r,t[1]=i);let a;t[2]===i?a=t[3]:(a=(0,$.jsx)(`h1`,{className:`typography-ui-header font-semibold text-foreground`,children:i}),t[2]=i,t[3]=a);let o;t[4]===r?o=t[5]:(o=r(`settings.view.home.description`),t[4]=r,t[5]=o);let s;t[6]===o?s=t[7]:(s=(0,$.jsx)(`p`,{className:`typography-ui text-muted-foreground`,children:o}),t[6]=o,t[7]=s);let c;t[8]!==a||t[9]!==s?(c=(0,$.jsxs)(`div`,{className:`space-y-1`,children:[a,s]}),t[8]=a,t[9]=s,t[10]=c):c=t[10];let l;t[11]===n?l=t[12]:(l=()=>n(`providers`),t[11]=n,t[12]=l);let u;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(u=q(`rounded-lg border border-border bg-[var(--surface-elevated)] p-4 text-left`,`hover:bg-[var(--interactive-hover)] transition-colors`),t[13]=u):u=t[13];let d;t[14]===r?d=t[15]:(d=r(`settings.view.home.cards.providers.title`),t[14]=r,t[15]=d);let f;t[16]===d?f=t[17]:(f=(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:d}),t[16]=d,t[17]=f);let p;t[18]===r?p=t[19]:(p=r(`settings.view.home.cards.providers.description`),t[18]=r,t[19]=p);let m;t[20]===p?m=t[21]:(m=(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground/70`,children:p}),t[20]=p,t[21]=m);let h;t[22]!==m||t[23]!==l||t[24]!==f?(h=(0,$.jsxs)(`button`,{type:`button`,onClick:l,className:u,children:[f,m]}),t[22]=m,t[23]=l,t[24]=f,t[25]=h):h=t[25];let g;t[26]===n?g=t[27]:(g=()=>n(`agents`),t[26]=n,t[27]=g);let _;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(_=q(`rounded-lg border border-border bg-[var(--surface-elevated)] p-4 text-left`,`hover:bg-[var(--interactive-hover)] transition-colors`),t[28]=_):_=t[28];let v;t[29]===r?v=t[30]:(v=r(`settings.view.home.cards.agents.title`),t[29]=r,t[30]=v);let y;t[31]===v?y=t[32]:(y=(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:v}),t[31]=v,t[32]=y);let b;t[33]===r?b=t[34]:(b=r(`settings.view.home.cards.agents.description`),t[33]=r,t[34]=b);let x;t[35]===b?x=t[36]:(x=(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground/70`,children:b}),t[35]=b,t[36]=x);let S;t[37]!==g||t[38]!==y||t[39]!==x?(S=(0,$.jsxs)(`button`,{type:`button`,onClick:g,className:_,children:[y,x]}),t[37]=g,t[38]=y,t[39]=x,t[40]=S):S=t[40];let C;t[41]===n?C=t[42]:(C=()=>n(`skills.catalog`),t[41]=n,t[42]=C);let w;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(w=q(`rounded-lg border border-border bg-[var(--surface-elevated)] p-4 text-left`,`hover:bg-[var(--interactive-hover)] transition-colors`),t[43]=w):w=t[43];let T;t[44]===r?T=t[45]:(T=r(`settings.view.home.cards.skillsCatalog.title`),t[44]=r,t[45]=T);let E;t[46]===T?E=t[47]:(E=(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:T}),t[46]=T,t[47]=E);let D;t[48]===r?D=t[49]:(D=r(`settings.view.home.cards.skillsCatalog.description`),t[48]=r,t[49]=D);let O;t[50]===D?O=t[51]:(O=(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground/70`,children:D}),t[50]=D,t[51]=O);let k;t[52]!==C||t[53]!==E||t[54]!==O?(k=(0,$.jsxs)(`button`,{type:`button`,onClick:C,className:w,children:[E,O]}),t[52]=C,t[53]=E,t[54]=O,t[55]=k):k=t[55];let A;t[56]===n?A=t[57]:(A=()=>n(`mcp`),t[56]=n,t[57]=A);let j;t[58]===Symbol.for(`react.memo_cache_sentinel`)?(j=q(`rounded-lg border border-border bg-[var(--surface-elevated)] p-4 text-left`,`hover:bg-[var(--interactive-hover)] transition-colors`),t[58]=j):j=t[58];let M;t[59]===r?M=t[60]:(M=r(`settings.view.home.cards.mcp.title`),t[59]=r,t[60]=M);let N;t[61]===M?N=t[62]:(N=(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:M}),t[61]=M,t[62]=N);let P;t[63]===r?P=t[64]:(P=r(`settings.view.home.cards.mcp.description`),t[63]=r,t[64]=P);let F;t[65]===P?F=t[66]:(F=(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground/70`,children:P}),t[65]=P,t[66]=F);let I;t[67]!==A||t[68]!==N||t[69]!==F?(I=(0,$.jsxs)(`button`,{type:`button`,onClick:A,className:j,children:[N,F]}),t[67]=A,t[68]=N,t[69]=F,t[70]=I):I=t[70];let L;t[71]===n?L=t[72]:(L=()=>n(`usage`),t[71]=n,t[72]=L);let R;t[73]===Symbol.for(`react.memo_cache_sentinel`)?(R=q(`rounded-lg border border-border bg-[var(--surface-elevated)] p-4 text-left`,`hover:bg-[var(--interactive-hover)] transition-colors`),t[73]=R):R=t[73];let z;t[74]===r?z=t[75]:(z=r(`settings.view.home.cards.usage.title`),t[74]=r,t[75]=z);let B;t[76]===z?B=t[77]:(B=(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:z}),t[76]=z,t[77]=B);let V;t[78]===r?V=t[79]:(V=r(`settings.view.home.cards.usage.description`),t[78]=r,t[79]=V);let H;t[80]===V?H=t[81]:(H=(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground/70`,children:V}),t[80]=V,t[81]=H);let U;t[82]!==L||t[83]!==B||t[84]!==H?(U=(0,$.jsxs)(`button`,{type:`button`,onClick:L,className:R,children:[B,H]}),t[82]=L,t[83]=B,t[84]=H,t[85]=U):U=t[85];let W;t[86]!==h||t[87]!==S||t[88]!==k||t[89]!==I||t[90]!==U?(W=(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[h,S,k,I,U]}),t[86]=h,t[87]=S,t[88]=k,t[89]=I,t[90]=U,t[91]=W):W=t[91];let ee;return t[92]!==W||t[93]!==c?(ee=(0,$.jsx)(`div`,{className:`h-full overflow-auto`,children:(0,$.jsxs)(`div`,{className:`mx-auto w-full max-w-3xl px-6 py-6 space-y-6`,children:[c,W]})}),t[92]=W,t[93]=c,t[94]=ee):ee=t[94],ee},gh=e=>{let t=(0,Ii.c)(182),{onClose:n,mobileInstancesPage:r,forceMobile:i,isWindowed:a,visiblePageSlugs:o,hideMobileHeader:s,flowMobile:c,autoOpenMobilePage:l,initialMobileStage:d,onMobileStageChange:f}=e,p=s!==void 0&&s,m=c!==void 0&&c,h=l===void 0||l,g=d===void 0?`nav`:d,{t:v}=Me(),y;t[0]===v?y=t[1]:(y={mutationFn:et,onError:()=>Oe.error(v(`chat.chatInput.toast.reloadFailed`))},t[0]=v,t[1]=y);let b=we(y),x;t[2]===b?x=t[3]:(x=()=>{b.isPending||b.mutate()},t[2]=b,t[3]=x);let S=Ae(x),C=yr(),T=i??C.isMobile,E=K(_h),D=K(vh),O=K(yh),k;t[4]===E?k=t[5]:(k=hi(E),t[4]=E,t[5]=k);let A=k;Hn();let j=A===`commands`,M;t[6]===j?M=t[7]:(M={enabled:j},t[6]=j,t[7]=M);let{refetch:N}=ot(M),P,F;t[8]!==N||t[9]!==A?(P=()=>{A===`commands`&&N()},F=[N,A],t[8]=N,t[9]=A,t[10]=P,t[11]=F):(P=t[10],F=t[11]),Q.useEffect(P,F);let[I,L]=Q.useState(g),R=p&&I===`nav`,z=T&&m,B=Q.useRef(null),V=Q.useRef(0),H=Kt(bh),U,W;t[12]!==T||t[13]!==H||t[14]!==O||t[15]!==A?(U=()=>{if(!T||H<=V.current)return;let e=Kt.getState().settingsSelectedAssistantID;if(!(!e||e===`new`)){if(A!==`assistants`){O(`assistants`);return}V.current=H,B.current=`assistants`,L(`page-content`)}},W=[T,H,O,A],t[12]=T,t[13]=H,t[14]=O,t[15]=A,t[16]=U,t[17]=W):(U=t[16],W=t[17]),Q.useEffect(U,W);let ee,G;t[18]!==I||t[19]!==f?(ee=()=>{f?.(I)},G=[I,f],t[18]=I,t[19]=f,t[20]=ee,t[21]=G):(ee=t[20],G=t[21]),Q.useEffect(ee,G);let[te,ne]=Q.useState(216),[re,ie]=Q.useState(``),[ae,oe]=Q.useState(null),[se,ce]=Q.useState(0),[le,ue]=Q.useState(!1),[de,fe]=Q.useState(!1),pe=Q.useRef(0),he=Q.useRef(te),ge=Q.useRef(null),_e=Q.useRef(null),ve=Q.useRef(null),ye=Q.useRef(null),be=Q.useRef(null),xe=Q.useRef(null),Se;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(Se=[],t[22]=Se):Se=t[22];let Ce=Q.useRef(Se),Te=Q.useRef(0),Ee=Q.useRef(!1),De;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(De=u(),t[23]=De):De=t[23];let ke=De,je;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(je=u()&&_(),t[24]=je):je=t[24];let Pe=je,Fe;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(Fe=u()&&typeof window<`u`&&window.__OPENCHAMBER_PLATFORM__===`darwin`,t[25]=Fe):Fe=t[25];let Ie=Fe,Le;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(Le=u()&&typeof window<`u`&&window.__OPENCHAMBER_PLATFORM__===`win32`,t[26]=Le):Le=t[26];let Re=Le,ze;t[27]===T?ze=t[28]:(ze=ch(ke,T),t[27]=T,t[28]=ze);let Be=ze,Ve;if(t[29]!==T||t[30]!==r||t[31]!==Be||t[32]!==o){let e=o?new Set(o):null,n;t[34]===Be?n=t[35]:(n=e=>lh(e,Be),t[34]=Be,t[35]=n);let i;t[36]===r?i=t[37]:(i=e=>e.slug!==`instances`||!!r,t[36]=r,t[37]=i);let a;t[38]===Be.isVSCode?a=t[39]:(a=e=>!(Be.isVSCode&&e.slug===`projects`),t[38]=Be.isVSCode,t[39]=a);let s;t[40]===T?s=t[41]:(s=e=>!(T&&e.slug===`shortcuts`),t[40]=T,t[41]=s),Ve=mi.filter(xh).filter(t=>!e||e.has(t.slug)).filter(n).filter(i).filter(a).filter(s),t[29]=T,t[30]=r,t[31]=Be,t[32]=o,t[33]=Ve}else Ve=t[33];let He=Ve,Ue;t[42]===He?Ue=t[43]:(Ue=ui(He),t[42]=He,t[43]=Ue);let We=Ue,Ge=Ct(Sh),qe,Je;t[44]===le?(qe=t[45],Je=t[46]):(qe=()=>{if(typeof window>`u`)return;let e=()=>{if(!le){let e=ah(Math.floor(window.innerWidth*.12));ne(e)}};return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},Je=[le],t[44]=le,t[45]=qe,t[46]=Je),Q.useEffect(qe,Je);let Ye,Xe;t[47]===de?(Ye=t[48],Xe=t[49]):(Ye=()=>{if(!de)return;let e=e=>{let t=e.clientX-pe.current,n=ah(he.current+t);ne(n),ue(!0)},t=()=>fe(!1);return window.addEventListener(`pointermove`,e),window.addEventListener(`pointerup`,t,{once:!0}),()=>{window.removeEventListener(`pointermove`,e),window.removeEventListener(`pointerup`,t)}},Xe=[de],t[47]=de,t[48]=Ye,t[49]=Xe),Q.useEffect(Ye,Xe);let Ze;t[50]===te?Ze=t[51]:(Ze=e=>{fe(!0),pe.current=e.clientX,he.current=te,e.preventDefault()},t[50]=te,t[51]=Ze);let Qe=Ze,$e;t[52]===te?$e=t[53]:($e=e=>{let t=e.shiftKey?32:rh,n;bb160:switch(e.key){case`ArrowLeft`:n=te-t;break bb160;case`ArrowRight`:n=te+t;break bb160;case`Home`:n=th;break bb160;case`End`:n=nh;break bb160;default:return}e.preventDefault(),ne(ah(n)),ue(!0)},t[52]=te,t[53]=$e);let Y=$e,tt;t[54]!==D||t[55]!==a||t[56]!==Be.isVSCode||t[57]!==A?(tt=()=>{if(!(!D&&!Be.isVSCode&&!a)){if(A===`agents`){Pt.getState().loadAgents();return}if(A!==`commands`&&A!==`mcp`){if(A===`plugins`){zc.getState().loadPlugins();return}(A===`skills.installed`||A===`skills.catalog`)&&Nt(w,dt()),A===`snippets`&&cn.getState().loadSnippets()}}},t[54]=D,t[55]=a,t[56]=Be.isVSCode,t[57]=A,t[58]=tt):tt=t[58];let nt;t[59]!==Ge||t[60]!==D||t[61]!==a||t[62]!==Be.isVSCode||t[63]!==A?(nt=[Ge,D,a,Be.isVSCode,A],t[59]=Ge,t[60]=D,t[61]=a,t[62]=Be.isVSCode,t[63]=A,t[64]=nt):nt=t[64],Q.useEffect(tt,nt);let rt;t[65]!==T||t[66]!==O?(rt=e=>{if(O(e),B.current=e,!T)return;let t=ii(e);if(!t||t.slug===`home`){L(`nav`);return}L(t.kind===`split`?`page-sidebar`:`page-content`)},t[65]=T,t[66]=O,t[67]=rt):rt=t[67];let it=rt,at;t[68]===A?at=t[69]:(at=ii(A),t[68]=A,t[69]=at);let st=at,ct;t[70]===Symbol.for(`react.memo_cache_sentinel`)?(ct={appearance:`visual`,chat:`chat`,shortcuts:`shortcuts`,sessions:`sessions`,"summary-ai":`summary-ai`,notifications:`notifications`,voice:`voice`},t[70]=ct):ct=t[70];let lt=ct,ut;t[71]===v?ut=t[72]:(ut=e=>{switch(e){case`projects`:return v(`settings.page.projects.title`);case`instances`:return v(`mobile.settings.switchInstance`);case`remote-instances`:return v(`settings.page.remoteInstances.title`);case`providers`:return v(`settings.page.providers.title`);case`usage`:return v(`settings.page.usage.title`);case`agents`:return v(`settings.page.agents.title`);case`assistants`:return v(`settings.page.assistants.title`);case`behavior`:return v(`settings.page.behavior.title`);case`commands`:return v(`settings.page.commands.title`);case`mcp`:return v(`settings.page.mcp.title`);case`plugins`:return v(`settings.page.plugins.title`);case`global-config`:return v(`settings.globalConfig.title`);case`skills.installed`:return v(`settings.page.skills.title`);case`skills.catalog`:return v(`settings.page.skillsCatalog.title`);case`git`:return v(`settings.page.git.title`);case`appearance`:return v(`settings.page.appearance.title`);case`chat`:return v(`settings.page.chat.title`);case`shortcuts`:return v(`settings.page.shortcuts.title`);case`sessions`:return v(`settings.page.sessions.title`);case`archived-sessions`:return v(`settings.page.archivedSessions.title`);case`summary-ai`:return v(`settings.page.summaryAI.title`);case`magic-prompts`:return v(`settings.page.magicPrompts.title`);case`snippets`:return v(`settings.page.snippets.title`);case`notifications`:return v(`settings.page.notifications.title`);case`voice`:return v(`settings.page.voice.title`);case`about`:return v(`settings.page.about.title`);default:return v(`settings.view.home.title`)}},t[71]=v,t[72]=ut);let ft=ut,pt;t[73]!==ft||t[74]!==Be||t[75]!==re||t[76]!==v||t[77]!==He?(pt=Qm({query:re,runtimeCtx:{...Be,isDesktopLocalOrigin:Pe,isMac:Ie,isWindows:Re},visiblePageSlugs:He.map(Ch),t:v,getPageTitle:ft}),t[73]=ft,t[74]=Be,t[75]=re,t[76]=v,t[77]=He,t[78]=pt):pt=t[78];let mt=pt,ht=kh,gt;if(t[79]!==mt){gt=[];let e=new Map;for(let t of mt){let n=e.get(t.page);n||(n={page:t.page,pageTitle:t.pageTitle,results:[]},e.set(t.page,n),gt.push(n)),n.results.push(t)}t[79]=mt,t[80]=gt}else gt=t[80];let _t=gt,vt;t[81]===Symbol.for(`react.memo_cache_sentinel`)?(vt=()=>{ce(0),Te.current=0,Ee.current=!1},t[81]=vt):vt=t[81];let yt;t[82]===re?yt=t[83]:(yt=[re],t[82]=re,t[83]=yt),Q.useEffect(vt,yt);let bt,xt;t[84]===se?(bt=t[85],xt=t[86]):(bt=()=>{Te.current=se},xt=[se],t[84]=se,t[85]=bt,t[86]=xt),Q.useEffect(bt,xt);let St,wt;t[87]===se?(St=t[88],wt=t[89]):(St=()=>{Ce.current[se]?.scrollIntoView({block:`nearest`})},wt=[se],t[87]=se,t[88]=St,t[89]=wt),Q.useEffect(St,wt);let Tt,Et;t[90]!==se||t[91]!==mt.length?(Tt=()=>{se>=mt.length&&ce(Math.max(0,mt.length-1)),Ce.current.length=mt.length},Et=[se,mt.length],t[90]=se,t[91]=mt.length,t[92]=Tt,t[93]=Et):(Tt=t[92],Et=t[93]),Q.useEffect(Tt,Et);let Dt;t[94]!==T||t[95]!==it?(Dt=e=>{let t=ht(e);oe(t),it(e.page),T&&L(`page-content`),e.id===`plugins.create`&&typeof window<`u`&&window.setTimeout(Ah,50)},t[94]=T,t[95]=it,t[96]=Dt):Dt=t[96];let Ot=Dt,kt;t[97]!==Ot||t[98]!==re||t[99]!==mt?(kt=e=>{if(re.trim()){if(e.key===`Escape`){e.preventDefault(),ie(``);return}if(mt.length!==0){if(e.key===`ArrowDown`){e.preventDefault(),Ee.current=!0,ce(e=>(e+1)%mt.length);return}if(e.key===`ArrowUp`){e.preventDefault(),Ee.current=!0,ce(e=>(e-1+mt.length)%mt.length);return}if(e.key===`Enter`){e.preventDefault();let t=(Te.current%mt.length+mt.length)%mt.length,n=mt[t]??mt[0];n&&Ot(n)}}}},t[97]=Ot,t[98]=re,t[99]=mt,t[100]=kt):kt=t[100];let At=kt,jt;t[101]===ae?jt=t[102]:(jt=()=>{let e=ae;if(!e)return;let t=!1,n=window.requestAnimationFrame(()=>{if(t)return;let n=typeof CSS<`u`&&CSS.escape?CSS.escape(e):e.replace(/[^a-zA-Z0-9_-]/g,`\\$&`),r=ge.current?.querySelector(`[data-settings-item="${n}"]`);r&&(oe(null),r.scrollIntoView({block:`center`,behavior:`smooth`}),r.setAttribute(`data-settings-search-highlight`,`true`),window.setTimeout(()=>{r.removeAttribute(`data-settings-search-highlight`)},1600))});return()=>{t=!0,window.cancelAnimationFrame(n)}},t[101]=ae,t[102]=jt);let Mt;t[103]!==ae||t[104]!==A?(Mt=[ae,A],t[103]=ae,t[104]=A,t[105]=Mt):Mt=t[105],Q.useEffect(jt,Mt);let Ft;t[106]===v?Ft=t[107]:(Ft=()=>(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center px-6`,children:(0,$.jsxs)(`div`,{className:`max-w-md text-center`,children:[(0,$.jsx)(`div`,{className:`typography-ui-header font-semibold text-foreground`,children:v(`settings.view.unavailable.title`)}),(0,$.jsx)(`p`,{className:`typography-ui text-muted-foreground mt-1`,children:v(`settings.view.unavailable.description`)})]})}),t[106]=v,t[107]=Ft);let It=Ft,Rt=jh,zt;t[108]!==T||t[109]!==Be.isVSCode||t[110]!==A?(zt=()=>{if(T){if(me()||Be.isVSCode){L(`page-sidebar`);return}if((typeof window<`u`?fh(window.history.state):null)?.page===A){window.history.back();return}L(`page-sidebar`)}},t[108]=T,t[109]=Be.isVSCode,t[110]=A,t[111]=zt):zt=t[111];let Bt=zt,Vt;t[112]!==Bt||t[113]!==T||t[114]!==z||t[115]!==r||t[116]!==it||t[117]!==It||t[118]!==Be?(Vt=e=>{let t=ii(e);if(t&&!lh(t,Be))return It();switch(e){case`home`:return(0,$.jsx)(hh,{onOpen:it});case`projects`:return(0,$.jsx)(Iu,{});case`instances`:return r??It();case`remote-instances`:return(0,$.jsx)(nf,{});case`agents`:return(0,$.jsx)(vo,{});case`assistants`:return(0,$.jsx)(zo,{onItemDeleted:T?Bt:void 0});case`behavior`:return(0,$.jsx)(Qo,{});case`commands`:return(0,$.jsx)(os,{});case`mcp`:return(0,$.jsx)(Gs,{});case`plugins`:return(0,$.jsx)(Fl,{});case`global-config`:return(0,$.jsx)(Rl,{});case`skills.installed`:return(0,$.jsx)(Du,{view:`installed`});case`skills.catalog`:return(0,$.jsx)(Du,{view:`catalog`});case`providers`:return(0,$.jsx)(Ef,{});case`usage`:return(0,$.jsx)(Qf,{});case`about`:return(0,$.jsx)(`div`,{className:q(`h-full overflow-auto px-5 py-6`,z&&`h-auto overflow-visible p-3`),children:(0,$.jsx)(Ki,{})});case`magic-prompts`:return(0,$.jsx)(sp,{});case`snippets`:return(0,$.jsx)(fp,{});case`git`:return(0,$.jsx)(bp,{});case`archived-sessions`:return(0,$.jsx)(Ym,{});case`appearance`:case`chat`:case`shortcuts`:case`sessions`:case`summary-ai`:case`notifications`:case`voice`:{let t=lt[e]??`visual`;return(0,$.jsx)(zm,{section:t,flowMobile:z})}default:return(0,$.jsx)(hh,{onOpen:it})}},t[112]=Bt,t[113]=T,t[114]=z,t[115]=r,t[116]=it,t[117]=It,t[118]=Be,t[119]=Vt):Vt=t[119];let Ht=Vt,Ut,Wt;t[120]!==h||t[121]!==T||t[122]!==I||t[123]!==A?(Ut=()=>{if(!T||!h||I!==`nav`||A===`home`||B.current===A)return;let e=ii(A);!e||e.slug===`home`||(B.current=A,L(e.kind===`split`?`page-sidebar`:`page-content`))},Wt=[h,T,I,A],t[120]=h,t[121]=T,t[122]=I,t[123]=A,t[124]=Ut,t[125]=Wt):(Ut=t[124],Wt=t[125]),Q.useEffect(Ut,Wt);let Gt,qt;t[126]!==m||t[127]!==A?(Gt=()=>{!m||A!==`home`||(B.current=null,L(`nav`))},qt=[m,A],t[126]=m,t[127]=A,t[128]=Gt,t[129]=qt):(Gt=t[128],qt=t[129]),Q.useEffect(Gt,qt);let Jt=T&&I!==`nav`,Yt=T&&I===`page-content`&&st?.kind===`split`,Xt=I===`page-content`&&st?.kind===`split`&&!Yt,Zt;t[130]!==Yt||t[131]!==Jt||t[132]!==v?(Zt=v(Yt?`settings.view.actions.back`:Jt?`settings.view.actions.backToSettings`:`settings.view.actions.closeSettings`),t[130]=Yt,t[131]=Jt,t[132]=v,t[133]=Zt):Zt=t[133];let Qt=Zt,$t=Ne(),en;t[134]===Be.isVSCode?en=t[135]:(en=e=>{if(typeof window>`u`||Be.isVSCode||me())return;let t=fh(window.history.state);(t?.page!==e||t.stage!==`page-content`)&&window.history.pushState({...ph(),[ih]:{page:e,stage:`page-content`}},``,window.location.href)},t[134]=Be.isVSCode,t[135]=en);let tn=en,nn;t[136]!==tn||t[137]!==A?(nn=()=>{L(`page-content`),tn(A)},t[136]=tn,t[137]=A,t[138]=nn):nn=t[138];let rn=nn,an;t[139]!==Yt||t[140]!==m||t[141]!==Bt||t[142]!==O?(an=()=>{if(m&&Lt.getState().settingsReturnTo){B.current=null,L(`nav`),O(`home`),Lt.getState().restoreSettingsReturnTo();return}if(Yt){Bt();return}L(`nav`)},t[139]=Yt,t[140]=m,t[141]=Bt,t[142]=O,t[143]=an):an=t[143];let on=an,sn;t[144]!==st?.kind||t[145]!==I?(sn=()=>{if(I===`page-content`){be.current=ye.current,xe.current=st?.kind===`split`?ve.current:_e.current;return}be.current=ve.current,xe.current=_e.current},t[144]=st?.kind,t[145]=I,t[146]=sn):sn=t[146];let ln=st?.kind,un;t[147]!==I||t[148]!==ln?(un=[ln,I],t[147]=I,t[148]=ln,t[149]=un):un=t[149],Q.useLayoutEffect(sn,un);let dn=`mobile-settings:${A}`,fn=z&&I!==`nav`,mn;t[150]!==on||t[151]!==dn||t[152]!==fn?(mn={id:dn,active:fn,onBack:on,surfaceRef:be,underlayRef:xe},t[150]=on,t[151]=dn,t[152]=fn,t[153]=mn):mn=t[153],Tr(mn);let gn,_n;t[154]!==T||t[155]!==Be.isVSCode||t[156]!==A?(gn=()=>{if(!T||Be.isVSCode||me())return;let e=e=>{if(ii(A)?.kind===`split`){if(fh(e.state)?.page===A){L(`page-content`);return}L(Mh)}};return window.addEventListener(`popstate`,e),()=>{window.removeEventListener(`popstate`,e)}},_n=[T,Be.isVSCode,A],t[154]=T,t[155]=Be.isVSCode,t[156]=A,t[157]=gn,t[158]=_n):(gn=t[157],_n=t[158]),Q.useEffect(gn,_n);let yn;t[159]===Symbol.for(`react.memo_cache_sentinel`)?(yn=()=>{L(`page-sidebar`)},t[159]=yn):yn=t[159];let bn=yn,xn=()=>{let e=re.trim().length>0;return(0,$.jsxs)(`div`,{className:q(`flex h-full flex-col overflow-hidden`,T&&`oc-settings-navigation-content`,z&&`h-auto w-full overflow-visible`),children:[(0,$.jsx)(`div`,{className:q(`px-2 pt-3`,T&&`oc-mobile-settings-search`),children:(0,$.jsxs)(`div`,{className:q(`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`,T&&`oc-mobile-settings-search-field`),children:[(0,$.jsx)(X,{name:`search`,className:`h-4 w-4 shrink-0`}),(0,$.jsx)(`input`,{value:re,onChange:e=>ie(e.target.value),onKeyDown:At,placeholder:v(`settings.view.search.placeholder`),"aria-label":v(`settings.view.search.aria`),className:`typography-ui min-w-0 flex-1 bg-transparent text-foreground outline-none placeholder:text-muted-foreground/70`}),e&&(0,$.jsx)(`button`,{type:`button`,onClick:()=>ie(``),"aria-label":v(`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:(0,$.jsx)(X,{name:`close`,className:`h-3.5 w-3.5`})})]})}),(0,$.jsx)(`div`,{className:q(`flex-1 min-h-0 overflow-y-auto overflow-x-hidden`,z&&`w-full flex-none overflow-visible`),children:(0,$.jsx)(`div`,{className:q(T?`oc-mobile-settings-nav-list flex min-w-0 flex-col`:`flex flex-col gap-0.5 px-2 pb-2 pt-4`),children:e?mt.length>0?(()=>{let e=0;return _t.map(t=>{let n=t.results.map(t=>{let n=e;e+=1;let r=n===se,i=!!t.description;return(0,$.jsxs)(`button`,{type:`button`,ref:e=>{Ce.current[n]=e},onMouseMove:()=>{Ee.current=!1,ce(n)},onClick:()=>Ot(t),className:q(T?`oc-mobile-settings-row oc-mobile-settings-search-result`:`flex w-full flex-col rounded-md px-2 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,i?`min-h-11 py-1.5`:`py-2`,r?`bg-interactive-selection`:`hover:bg-interactive-hover`),children:[(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground truncate`,children:t.title}),i&&(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground/70 line-clamp-2`,children:t.description})]}),T?(0,$.jsx)(X,{name:`arrow-right-s`,className:`size-4 shrink-0 text-muted-foreground/60`}):null]},t.id)});return T?(0,$.jsx)($m,{label:t.pageTitle,ariaLabel:t.pageTitle,children:n},t.page):(0,$.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,$.jsx)(`div`,{className:`px-2 pb-0.5 pt-2 typography-micro font-medium text-muted-foreground/70`,children:t.pageTitle}),n]},t.page)})})():(0,$.jsx)(`div`,{className:`px-2 py-6 text-center typography-ui text-muted-foreground`,children:v(`settings.view.search.noResults`)}):(0,$.jsx)($.Fragment,{children:We.map((e,t)=>{let{group:n,pages:r}=e,i=v(`settings.view.navigation.groups.${n}`),a=r.map(e=>{let t=A===e.slug,n=mh(e.slug);return!n&&e.slug!==`mcp`?null:(0,$.jsx)(hn,{children:(0,$.jsx)(pn,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>it(e.slug),"aria-current":t?`page`:void 0,className:q(T?`oc-mobile-settings-row`:`flex h-8 w-full items-center gap-2 overflow-hidden rounded-md px-2 text-left`,t&&!T?`bg-interactive-selection text-foreground`:`text-foreground hover:bg-interactive-hover`),children:[e.slug===`mcp`?(0,$.jsx)(Vr,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(X,{name:n,className:`h-4 w-4 shrink-0`}),(0,$.jsx)(`span`,{className:`flex min-w-0 flex-1 items-center gap-1.5 overflow-hidden whitespace-nowrap transition-opacity duration-150 opacity-100`,children:(0,$.jsx)(`span`,{className:`typography-ui-label font-normal truncate`,children:ft(e.slug)})}),T?(0,$.jsx)(X,{name:`arrow-right-s`,className:`size-4 shrink-0 text-muted-foreground/60`}):null]})})},e.slug)});return T?(0,$.jsx)($m,{label:i,ariaLabel:i,children:a},n):(0,$.jsxs)(`div`,{className:q(`space-y-0.5`,t>0&&`pt-3`),children:[(0,$.jsx)(`div`,{className:`px-2 pb-0.5 typography-micro font-medium text-muted-foreground/70`,children:i}),a]},n)})})})}),(0,$.jsx)(`div`,{className:q(`overflow-hidden transition-opacity duration-150 opacity-100`,T&&`oc-mobile-settings-footer`),children:(0,$.jsx)(`div`,{className:q(`border-t-[0.5px] border-border/40 bg-sidebar px-2 py-1 space-y-0.5`,T&&`oc-mobile-floating-surface oc-mobile-settings-card`),children:!Be.isVSCode&&(0,$.jsxs)(J,{type:`button`,variant:`ghost`,size:`sm`,disabled:b.isPending,"aria-busy":b.isPending,className:q(T?`oc-mobile-settings-row`:`w-full justify-start overflow-hidden`,`text-sm font-semibold text-sidebar-foreground/90`,`hover:text-sidebar-foreground hover:bg-interactive-hover`),onClick:S,children:[(0,$.jsx)(X,{name:`restart`,className:q(`h-4 w-4 shrink-0`,b.isPending&&`animate-spin`)}),(0,$.jsx)(`span`,{children:v(`settings.view.actions.reloadOpenCode`)})]})})})]})},Sn=()=>(0,$.jsx)(`div`,{className:q(`flex-1 min-h-0 overflow-hidden`,z?`w-full flex-none overflow-visible bg-transparent`:Be.isVSCode?`bg-background`:`bg-sidebar`),children:(0,$.jsx)(`div`,{className:q(`flex h-full min-h-0 flex-col`,z&&`h-auto w-full overflow-visible`),children:(0,$.jsx)(vn,{children:xn()})})}),Cn=e=>{let t=e===void 0?I:e;if(t===`nav`)return Sn();let n=q(`flex-1 min-h-0 overflow-hidden bg-transparent`,z?`w-full flex-none overflow-visible`:`px-[var(--oc-mobile-page-inline-inset)]`);if(!st)return(0,$.jsx)(`div`,{className:n});if(t===`page-sidebar`){if(st.kind!==`split`){let e=Ht(A);return(0,$.jsx)(`div`,{className:n,children:(0,$.jsx)(fi,{className:`oc-mobile-settings-detail-card`,children:(0,$.jsx)(vn,{children:e})})})}return(0,$.jsx)(`div`,{className:n,children:(0,$.jsx)(fi,{className:`oc-mobile-settings-detail-card`,children:(0,$.jsx)(vn,{children:Rt(A,{onItemSelect:rn})})})})}let r=Ht(A);return(0,$.jsx)(`div`,{className:n,children:(0,$.jsx)(fi,{className:`oc-mobile-settings-detail-card`,children:(0,$.jsx)(vn,{children:r})})})},wn;t[160]!==st||t[161]!==it||t[162]!==Ht||t[163]!==Be.isVSCode||t[164]!==A?(wn=()=>!st||A===`home`?(0,$.jsx)(hh,{onOpen:it}):st.kind===`split`?(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 overflow-hidden`,children:[(0,$.jsx)(`div`,{className:q(`w-[264px] min-w-[264px] border-r-[0.5px] border-border/40`,Be.isVSCode?`bg-background`:`bg-sidebar`),children:(0,$.jsx)(vn,{children:Rt(A,{})})}),(0,$.jsx)(`div`,{className:`flex-1 min-h-0 overflow-hidden bg-background`,children:(0,$.jsx)(vn,{children:Ht(A)})})]}):(0,$.jsx)(`div`,{className:`h-full min-h-0 overflow-hidden bg-background`,children:(0,$.jsx)(vn,{children:Ht(A)})}),t[160]=st,t[161]=it,t[162]=Ht,t[163]=Be.isVSCode,t[164]=A,t[165]=wn):wn=t[165];let Tn=wn,En=e=>(0,$.jsx)(Ke,{sticky:!0,title:(e===void 0?I:e)===`nav`?v(`settings.view.home.title`):st?ft(st.slug):v(`settings.view.home.title`),backAriaLabel:Qt,onBack:Jt?on:n,actions:[...Xt?[{icon:`list-unordered`,ariaLabel:v(`settings.view.actions.openSectionList`),onClick:bn}]:[],...n?[{icon:`close`,ariaLabel:v(`settings.view.actions.closeSettings`),title:v(`settings.view.actions.closeSettingsWithShortcut`,{shortcut:$t}),onClick:n}]:[]]});if(z){let e=I!==`nav`,n=e&&st?.kind===`split`,r=I===`page-content`,i=I===`page-sidebar`,a=r&&st?.kind===`split`,o=e&&!a,s;t[166]===v?s=t[167]:(s=v(`mobile.settings.placeholder.title`),t[166]=v,t[167]=s);let c;return t[168]===s?c=t[169]:(c=(0,$.jsx)(ni,{title:s}),t[168]=s,t[169]=c),(0,$.jsxs)(`div`,{ref:ge,"data-settings-view":`true`,"data-mobile-settings-detail-active":e?`true`:void 0,className:`oc-settings-workspace oc-settings-workspace-mobile h-auto w-full min-w-0 overflow-visible bg-transparent`,children:[(0,$.jsxs)(`div`,{ref:_e,"data-mobile-settings-stage":`nav`,"data-mobile-navigation-underlay":o?`true`:void 0,"aria-hidden":e?`true`:void 0,inert:e?!0:void 0,className:`oc-mobile-settings-root-surface fixed inset-0 z-20 flex h-[100dvh] w-full min-w-0 max-w-full flex-col gap-[var(--oc-mobile-page-gap)] overflow-y-auto overflow-x-hidden overscroll-contain px-[var(--oc-mobile-page-inline-inset)] pb-[calc(var(--oc-mobile-dock-height)+2.5rem+var(--oc-safe-area-bottom,env(safe-area-inset-bottom,0px)))] pt-[calc(var(--oc-safe-area-top,env(safe-area-inset-top,0px))+1rem)] [contain:layout_paint]`,children:[c,Sn()]}),n?(0,$.jsxs)(`div`,{ref:ve,"data-mobile-settings-stage":`page-sidebar`,"data-mobile-navigation-underlay":a?`true`:void 0,"data-mobile-settings-push-surface":`true`,"aria-hidden":i?void 0:`true`,inert:!i||void 0,className:`fixed inset-0 z-40 flex h-[100dvh] w-full min-w-0 max-w-full touch-pan-y flex-col overflow-hidden bg-background [contain:layout_paint]`,children:[En(`page-sidebar`),(0,$.jsx)(`div`,{className:`min-h-0 w-full flex-1 overflow-y-auto overflow-x-hidden overscroll-contain px-[var(--oc-mobile-page-inline-inset)]`,children:Cn(`page-sidebar`)})]}):null,r?(0,$.jsxs)(`div`,{ref:ye,"data-mobile-settings-stage":`page-content`,"data-mobile-settings-push-surface":`true`,className:`fixed inset-0 z-50 flex h-[100dvh] w-full min-w-0 max-w-full touch-pan-y flex-col overflow-hidden bg-background [contain:layout_paint]`,children:[En(`page-content`),(0,$.jsx)(`div`,{className:`min-h-0 w-full flex-1 overflow-y-auto overflow-x-hidden overscroll-contain px-[var(--oc-mobile-page-inline-inset)]`,children:Cn(`page-content`)})]}):null]})}let Dn=T?`oc-settings-workspace-mobile bg-transparent`:`oc-settings-workspace-desktop bg-background`,On=z&&`h-auto w-full overflow-visible`,kn;t[170]!==Dn||t[171]!==On?(kn=q(`oc-settings-workspace relative flex h-full min-h-0 flex-col overflow-hidden`,Dn,On),t[170]=Dn,t[171]=On,t[172]=kn):kn=t[172];let An=T&&!R?En():T?null:(0,$.jsxs)($.Fragment,{children:[Jt&&(0,$.jsx)(`div`,{className:q(`absolute left-3 z-50`,a?`top-2`:`top-3`),children:(0,$.jsx)(`button`,{type:`button`,onClick:on,"aria-label":v(`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:(0,$.jsx)(X,{name:`arrow-left-s`,className:`h-5 w-5`})})}),n&&(0,$.jsx)(`div`,{className:q(`absolute right-0.5 z-50`,a?`top-0.5`:`top-1`),children:(0,$.jsx)(`button`,{type:`button`,onClick:n,"aria-label":v(`settings.view.actions.closeSettings`),title:v(`settings.view.actions.closeSettingsWithShortcut`,{shortcut:$t}),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:(0,$.jsx)(X,{name:`close`,className:`h-5 w-5`})})})]}),jn=z&&`w-full flex-none overflow-visible`,Mn;t[173]===jn?Mn=t[174]:(Mn=q(`flex flex-1 min-h-0 overflow-hidden`,jn),t[173]=jn,t[174]=Mn);let Nn=T?Cn():(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:q(`relative flex h-full min-h-0 flex-col overflow-hidden border-r-[0.5px] border-border/40`,ke?`bg-sidebar`:Be.isVSCode?`bg-background`:`bg-sidebar`,de?``:`transition-[width,min-width] duration-200 ease-[cubic-bezier(0.25,0.1,0.25,1)]`),style:{width:`${te}px`,minWidth:`${te}px`},children:[(0,$.jsx)(`div`,{className:q(`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)]`,de?`bg-primary/30`:`bg-transparent hover:bg-primary/20`),tabIndex:0,onPointerDown:Qe,onKeyDown:Y,role:`separator`,"aria-orientation":`vertical`,"aria-valuemin":th,"aria-valuemax":nh,"aria-valuenow":te,"aria-label":v(`settings.view.actions.resizeNavigation`)}),(0,$.jsx)(vn,{children:xn()})]}),(0,$.jsx)(`div`,{className:`oc-settings-detail-pane flex-1 overflow-hidden bg-background`,children:Tn()})]}),Pn;t[175]!==Mn||t[176]!==Nn?(Pn=(0,$.jsx)(`div`,{className:Mn,children:Nn}),t[175]=Mn,t[176]=Nn,t[177]=Pn):Pn=t[177];let Fn;return t[178]!==kn||t[179]!==An||t[180]!==Pn?(Fn=(0,$.jsxs)(`div`,{ref:ge,"data-settings-view":`true`,className:kn,children:[An,Pn]}),t[178]=kn,t[179]=An,t[180]=Pn,t[181]=Fn):Fn=t[181],Fn};function _h(e){return e.settingsPage}function vh(e){return e.isSettingsDialogOpen}function yh(e){return e.setSettingsPage}function bh(e){return e.openSettingsRequestRevision}function xh(e){return e.slug!==`home`}function Sh(e){return e.activeProjectId}function Ch(e){return e.slug}function wh(e){return e.name}function Th(e){return e.name}function Eh(e){return e.name}function Dh(e){return e.name}function Oh(e){return e.name}function kh(e){if(e.id.startsWith(`assistants.`)){if(e.id===`assistants.instance-enabled`)return e.id;if(e.id===`assistants.default-share`){let t=Kt.getState(),n=Be()?.assistants??[],r=n.some(e=>e.id===t.settingsSelectedAssistantID);return t.selectSettingsAssistant(r?t.settingsSelectedAssistantID:n[0]?.id??null),e.id}return Kt.getState().requestCreate(),e.id===`assistants.create`?`assistants.name`:e.id}if(e.id.startsWith(`agents.`)){let t=Pt.getState(),n=dh(`new-agent`,it().map(wh));return t.setAgentDraft({name:n,scope:`user`}),t.setSelectedAgent(n),e.id===`agents.create`?`agents.name`:e.id}if(e.id.startsWith(`commands.`)){let t=ra.getState(),n=dh(`new-command`,rt().map(Th));return t.setCommandDraft({name:n,scope:`user`}),t.setSelectedCommand(n),e.id===`commands.create`?`commands.name`:e.id}if(e.id.startsWith(`mcp.`)){let t=la.getState(),n=dh(`new-mcp-server`,wi().map(Eh));return t.setMcpDraft({name:n,scope:`user`,type:`local`,command:[],url:``,environment:[],headers:[],oauthEnabled:!0,oauthClientId:``,oauthClientSecret:``,oauthScope:``,oauthRedirectUri:``,timeout:``,enabled:!0}),t.setSelectedMcp(n),e.id===`mcp.create`?`mcp.server`:e.id}if(e.id.startsWith(`snippets.`)){let t=cn.getState(),n=dh(`new-snippet`,t.snippets.map(Dh));return t.setSnippetDraft({name:n,scope:`global`}),t.setSelectedSnippet(n),e.id===`snippets.create`?`snippets.content`:e.id}if(e.id.startsWith(`skills.`)){let t=Qe(w),n=ma.getState(),r=dh(`new-skill`,t.map(Oh));return n.setSkillDraft({name:r,scope:`user`,source:`opencode`,description:``,instructions:``}),n.setSelectedSkill(r),e.id===`skills.create`?`skills.basic-information`:e.id}return e.id===`providers.connect`&&Mt.getState().setSelectedProvider(sh),e.id===`plugins.create`?`plugins.spec`:e.id}function Ah(){window.dispatchEvent(new CustomEvent(`openchamber:settings-open-plugin-add`))}function jh(e,t){switch(e){case`projects`:return(0,$.jsx)(ku,{onItemSelect:t.onItemSelect});case`agents`:return(0,$.jsx)(Wa,{onItemSelect:t.onItemSelect});case`assistants`:return(0,$.jsx)(Ro,{onItemSelect:t.onItemSelect});case`commands`:return(0,$.jsx)($o,{onItemSelect:t.onItemSelect});case`mcp`:return(0,$.jsx)(us,{onItemSelect:t.onItemSelect});case`plugins`:return(0,$.jsx)(hl,{onItemSelect:t.onItemSelect});case`skills.installed`:return(0,$.jsx)(Vl,{onItemSelect:t.onItemSelect});case`providers`:return(0,$.jsx)(of,{onItemSelect:t.onItemSelect});case`usage`:return(0,$.jsx)(Af,{onItemSelect:t.onItemSelect});case`magic-prompts`:return(0,$.jsx)(tp,{onItemSelect:t.onItemSelect});case`snippets`:return(0,$.jsx)(cp,{onItemSelect:t.onItemSelect});default:return null}}function Mh(e){return e===`page-content`?`page-sidebar`:e}export{la as a,Ji as c,zo as i,qi as l,eh as n,Qi as o,nd as r,Yi as s,gh as t,Ki as u};
|